• 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?

    Input

    The first line contains an integer tt (1t5001≤t≤500) — the number of test cases to solve.

    Each of the remaining tt lines contains integers aa, bb and cc (0a,b,c100≤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.

    Output

    For each test case print a single integer — the maximum number of visitors Denis can feed.

    Example
    Input
     
    7
    1 2 1
    0 0 0
    9 1 7
    2 2 3
    2 3 2
    3 2 2
    4 4 4
    Output
     
    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;
    }
  • 相关阅读:
    Visual Studio 2010 SP1 中文升级补丁ISO完整版下载 (含多国语言)
    通过修改Host实现chrome同步
    附加数据库出现 无法打开物理文件 操作系统错误 5:拒绝访问 SQL
    配置Oracle遇到问题<一>
    GDI+中发生一般性错误的解决办法(转载)
    当VS和Flash builder同时运行时
    抛弃jQuery 深入原生的JavaScript
    Android SDK下载和更新慢或失败的解决办法
    Android 学习笔记 文本文件的读写操作
    Android Camera相机功能实现 拍照并保存图片
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/12356846.html
Copyright © 2020-2023  润新知