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 ...
随机推荐
- 【Python】输入身份证号,输出出生日期
name = input("请输入你的名字:") id = input("请输入你的身份证号码:") year = id[6:10] month = id[10 ...
- [一本通学习笔记] 字典树与 0-1 Trie
字典树中根到每个结点对应原串集合的一个前缀,这个前缀由路径上所有转移边对应的字母构成.我们可以对每个结点维护一些需要的信息,这样即可以去做很多事情. #10049. 「一本通 2.3 例 1」Phon ...
- 03-Java基础语法【 流程控制语句】
重要知识记录: 1.流程控制 顺序结构:根据编写的顺序,从上到下进行运行. 2.判断语句 1)判断语句1--if if(判断条件){ 执行语句: } 2)判断语句2--if...else if(判断条 ...
- C语言数据结构——第四章 串
四.串 4.1-串的基本概念 串的定义 串是由数字.字母或其他字符组成的有限序列,一般记为 StringName = “a[0]a[1]a[2]···a[i]···a[n-1]”(n>0,0&l ...
- php:对象(object)数据类型实例详解
什么是对象? 对象是存储数据和有关如何处理数据的信息的数据类型.是系统中用来描述客观事物的一个实体,它是构成系统的一个基本单位.一个对象由一组属性和对这组属性进行操作的一组服务组成. 语法 在 PHP ...
- 问题 I: 数字分组2
问题 I: 数字分组2 时间限制: 1 Sec 内存限制: 128 MB[命题人:admin] 题目描述 已知一堆魔法石的重量,问如何分成两堆,使得它们质量和之差最大,但不能大于(可以等于)这些数中 ...
- biquad filter实现
原始频谱: LPF: HPF: 代码: #include<stdio.h> #include<stdlib.h> #include<errno.h> #includ ...
- 隐藏wordpress版本信息
在主题中的functions.php中添加如下代码: remove_action( 'wp_head', 'wp_generator');
- hdu 1532 Drainage Ditches(网络流)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1532 题目大意是:农夫约翰要把多个小池塘的水通过池塘间连接的水渠排出去,从池塘1到池塘M最多可以排多少 ...
- 关于Excel,你一定用的到的36个Python函数
从Excel到Python:最常用的36个Pandas函数关于Excel,你一定用的到的36个Python函数 本文涉及pandas最常用的36个函数,通过这些函数介绍如何完成数据生成和导入.数据清洗 ...