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[];
cin>>a[]>>a[]>>a[];
sort(a,a+);
int cnt=;
if(a[])cnt++,a[]--;
if(a[])cnt++,a[]--;
if(a[])cnt++,a[]--;
if(a[]>&&a[]>)cnt++,a[]--,a[]--;//贪心分配
if(a[]>&&a[]>)cnt++,a[]--,a[]--;
if(a[]>&&a[]>)cnt++,a[]--,a[]--;
if(a[]>&&a[]>&&a[]>)cnt++;
cout<<cnt<<endl;
}
return ;
}
Codeforces Round #622 (Div. 2) A. Fast Food Restaurant的更多相关文章
- Codeforces Round #622 (Div. 2) A. Fast Food Restaurant(全排列,DFS)
Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最 ...
- Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version)(单调栈,递推)
Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version) 题意: 你是一名建筑工程师,现给出 n 幢建筑的预计建设高度,你想建成峰状, ...
- Codeforces Round #622 (Div. 2) B. Different Rules(数学)
Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n ...
- Codeforces Round #622 (Div. 2) 1313 A
Tired of boring office work, Denis decided to open a fast food restaurant. On the first day he made ...
- Codeforces Round #622 (Div. 2).C2 - Skyscrapers (hard version)
第二次写题解,请多多指教! http://codeforces.com/contest/1313/problem/C2 题目链接 不同于简单版本的暴力法,这个数据范围扩充到了五十万.所以考虑用单调栈的 ...
- Codeforces Round #622 (Div. 2)C2 Skyscrapers最大"尖"性矩形,思维||分治
题:https://codeforces.com/contest/1313/problem/C2 题意:给出n个数,分别代表第i个位置所能搭建的最大高度,问以哪一个位置的塔的高度为基准向左的每一个塔都 ...
- Codeforces Round #622 (Div. 2) 1313 B Different Rules
B. Different Rules Nikolay has only recently started in competitive programming, but already qualifi ...
- Codeforces Round #622(Div 2) C1. Skyscrapers (easy version)
题目链接: C1. Skyscrapers (easy version) 题目描述: 有一行数,使得整个序列满足 先递增在递减(或者只递增,或者只递减) ,每个位置上的数可以改变,但是最大不能超过原来 ...
- Codeforces Round #622 (Div. 2) C2 - Skyscrapers (hard version) 单调栈
从左往右扫,找到比第i个小的第一个数字,l[i] = l[last] + (i - last) * m[i],用单调栈O(n)维护这个过程,再从右往左扫,同理可以算出r数组,注意一下long long ...
随机推荐
- 读书笔记 (.NET企业级应用架构设计)
建议你自己和别人多沟通(学会沟通会使你在公司更好的发展,有意见就提,有问题就问,有困难就说)加油lxp 1.架构师是用来干嘛的: 架构师分析需求,分析系统要去做什么,架构怎么去做 2.架构师的职责是: ...
- nginx的配置总结,有时间自己整理
推荐文章:https://www.cnblogs.com/digdeep/p/4217310.html
- Visibility Graph Analysis of Geophysical Time Series: Potentials and Possible Pitfalls
Tasks: invest papers 3 篇. 研究主动权在我手里. I have to. 1. the benefit of complex network: complex networ ...
- python3练习100题——008
今天第二道,做了明天就可以休息一下- 原题链接:http://www.runoob.com/python/python-exercise-example8.html 题目:输出 9*9 乘法口诀表. ...
- AcWing 3. 完全背包问题
朴素 #include<iostream> #include<algorithm> using namespace std ; ; int n,m; int v[N],w[N] ...
- 怎么把html页面部署到云服务器上
1,下载nginx 2,把页面放置到云服务器上 3,通过配置nginx conf下的nginx.conf文件,就可以通过ip:port访问到了 链接:https://www.cnblogs.com/f ...
- 1.3、WebRTC架构
文章导读:本文的讲解的是webrtc系统架构,每个人都要Get到这些知识:第一.了解webrtc架构分层:第二.对每层技术有一个清晰的认知.学完本节内容可以为我们后面学习核心API起到至关重要的作用, ...
- sqlserver表中导入大批量数据
背景: 想要往sqlserver数据库中导入大批量数据,使得数据库的备份文件大于几个G. 注意: 导入的数据不能太规范,数据表最好不一致,否则会自动压缩. 解决办法: 1)通过excel导入,可以参考 ...
- Python记:列表和元组之序列相加
_______________坐而论道,不如起而行之! 序列乘法运算示例:
- Nginx可以做什么
Nginx能做什么 ——反向代理 ——负载均衡 ——HTTP服务器(动静分离) ——正向代理 反向代理 反向代理应该是Nginx做的最多的一件事了,什么是反向代理呢,以下是百度百科的说法:反向代理(R ...