zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    CEPH篇 CEPH接口(S3)
    MAC篇 超级简单的连接远程主机方法(永久记住)
    【思维论01】如何让自己像打王者荣耀一样发了疯、石乐志的学习?
    CEPH篇 CEPH部署(在线和离线 Centos 7)
    JAVA优化篇 如何从茫茫日志中找到运行缓慢的线程
    CEPH篇 块存储、文件存储和对象存储意义和差异
    CEPH篇 简介及关键对象解释
    混合使用Jquery Deferred和Angularjs的$timeout(转)
    AngularJs应用页面切换优化方案(转)
    在IE7下使用angularjs(转)
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/12356846.html
Copyright © 2011-2022 走看看