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;
    }
  • 相关阅读:
    微信——获取用户基本信息及openid 、access_token、code
    Java中的标记接口(zz)
    深入理解Java的注解(Annotation):注解处理器(3)
    深入理解Java的注解(Annotation):自定义注解入门(2)
    深入理解Java的注解(Annotation):基本概念(1)
    TCP 粘包及其解决方案(zz)
    TCP,UDP,IP包头格式及说明(zz)
    python 如何将JSON数据原封不动的转为字符串(顺序不能变动)?
    mysql:functional dependency
    什么是“几何级数”?什么是“算数级数”?有啥区别?
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/12356846.html
Copyright © 2011-2022 走看看