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 ...
随机推荐
- selenium获取短暂出现元素的xpath路径
1. pip install beautifulsoup4 :安装beautifulsoup4 2. from bs4 import BeautifulSoup 3. bs = BeautifulS ...
- 查看杀死django进程
#命令:#用于显示tcp,udp的端口和进程等相关情况netstat -tunlp"""ps:-t (tcp)仅显示tcp相关选项-u (udp)仅显示udp相关选项-n ...
- 洛谷 P5569 [SDOI2008]石子合并 GarsiaWachs算法
石子合并终极通用版 #include<bits/stdc++.h> using namespace std ; ]; int n,t,ans; void combine(int k) { ...
- 题解【Codeforces438D】The Child and Sequence
题目描述 At the children's day, the child came to Picks's house, and messed his house up. Picks was angr ...
- node 崩 处理
node_modules->bin webpack-dev-server.cmd @IF EXIST "%~dp0\node.exe" ( "%~dp0\node. ...
- winform学习(8)RichTextBox控件
RichTextBox控件允许用户输入和编辑文本的同时提供了比普通的TextBox控件更高级的格式特征. RichTextBox的控件标识符.SelectionColor = Color.Blue; ...
- 【c++】零基础的自修课 01-开发工具的安装(code::blocks)
1/开发工具的下载地址: ·(选用 visual studio开发工具,有区分mac和windows版本)https://visualstudio.microsoft.com/zh-hans/down ...
- 【转载】Mapreduce实现自定义的InputFormat
转自:http://www.cnblogs.com/dlutxm/archive/2011/09/30/2196653.html 在mapreduce程序运行的开始阶段,hadoop需要将待处理的输入 ...
- linux 网卡限速
#安装git yum -y install git #下载wondershaper git clone https://github.com/magnific0/wondershaper.git 第 ...
- 机器学习基础梳理—(accuracy,precision,recall浅谈)
一.TP TN FP FN TP:标签为正例,预测为正例(P),即预测正确(T) TN:标签为负例,预测为负例(N),即预测正确(T) FP:标签为负例,预测为正例(P),即预测错误(F) FN:标签 ...