Codeforces Round #622 (Div. 2) A. Fast Food Restaurant
Tired of boring office work, Denis decided to open a fast food restaurant.
On the first day he made aa portions of dumplings, bb portions of cranberry juice and cc pancakes with condensed milk.
The peculiarity of Denis's restaurant is the procedure of ordering food. For each visitor Denis himself chooses a set of dishes that this visitor will receive. When doing so, Denis is guided by the following rules:
- every visitor should receive at least one dish (dumplings, cranberry juice, pancakes with condensed milk are all considered to be dishes);
- each visitor should receive no more than one portion of dumplings, no more than one portion of cranberry juice and no more than one pancake with condensed milk;
- all visitors should receive different sets of dishes.
What is the maximum number of visitors Denis can feed?
The first line contains an integer tt (1≤t≤5001≤t≤500) — the number of test cases to solve.
Each of the remaining tt lines contains integers aa, bb and cc (0≤a,b,c≤100≤a,b,c≤10) — the number of portions of dumplings, the number of portions of cranberry juice and the number of condensed milk pancakes Denis made.
For each test case print a single integer — the maximum number of visitors Denis can feed.
7
1 2 1
0 0 0
9 1 7
2 2 3
2 3 2
3 2 2
4 4 4
3
0
4
5
5
5
7
思维题,需要贪心一下。可以想到最多只有其中配餐情况。先把输入的三个数sort一下。先考虑只发一种的情况,分别判断三个数是否大于0,是的话ans++,原数--。然后判断两种的情况,这里要注意,要贪心地优先拿数量最多的菜和较少的两种搭配(顺序无所谓) 可以考虑一个样例的2 2 3.然后三种菜全选的话直接判断能不能满足就行。
#include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int a[3]; cin>>a[0]>>a[1]>>a[2]; sort(a,a+3); int cnt=0; if(a[0])cnt++,a[0]--; if(a[1])cnt++,a[1]--; if(a[2])cnt++,a[2]--; if(a[0]>0&&a[2]>0)cnt++,a[0]--,a[2]--;//贪心分配 if(a[1]>0&&a[2]>0)cnt++,a[1]--,a[2]--; if(a[0]>0&&a[1]>0)cnt++,a[0]--,a[1]--; if(a[0]>0&&a[1]>0&&a[2]>0)cnt++; cout<<cnt<<endl; } return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!