zoukankan      html  css  js  c++  java
  • 2017 JUST Programming Contest 3.0 E. The Architect Omar

    E. The Architect Omar
    time limit per test
    1.0 s
    memory limit per test
    256 MB
    input
    standard input
    output
    standard output

    Architect Omar is responsible for furnishing the new apartments after completion of its construction. Omar has a set of living room furniture, a set of kitchen furniture, and a set of bedroom furniture, from different manufacturers.

    In order to furnish an apartment, Omar needs a living room furniture, a kitchen furniture, and two bedroom furniture, regardless the manufacturer company.

    You are given a list of furniture Omar owns, your task is to find the maximum number of apartments that can be furnished by Omar.

    Input

    The first line contains an integer T (1 ≤ T ≤ 100), where T is the number of test cases.

    The first line of each test case contains an integer n (1 ≤ n ≤ 1000), where n is the number of available furniture from all types. Then nlines follow, each line contains a string s representing the name of a furniture.

    Each string s begins with the furniture's type, then followed by the manufacturer's name. The furniture's type can be:

    • bed, which means that the furniture's type is bedroom.
    • kitchen, which means that the furniture's type is kitchen.
    • living, which means that the furniture's type is living room.

    All strings are non-empty consisting of lowercase and uppercase English letters, and digits. The length of each of these strings does not exceed 50 characters.

    Output

    For each test case, print a single integer that represents the maximum number of apartments that can be furnished by Omar

    Example
    input
    1
    6
    bedXs
    kitchenSS1
    kitchen2
    bedXs
    living12
    livingh
    
    output
    1
    

    #include <iostream>
    #include<string>
    #include<math.h>
    #include<algorithm>
    #include<string.h>
    using namespace std;
    const int maxn=1010;
    //int b[maxn],k[maxn],l[maxn];
    int main()
    {
        int t;
        cin>>t;
        while(t--)
        {
            int n;
            int b=0,l=0,k=0;
            cin>>n;
            string str;
            while(n--)
            {
                cin>>str;
                if(str[0]=='b')
                {
                    b++;
                }
                else if(str[0]=='k')
                {
                    k++;
                }
                else
                {
                    l++;
                }
            }
            int b1=b/2;
            int tmp=b1;
            tmp=min(tmp,k);
            tmp=min(tmp,l);
            cout<<tmp<<endl;
        }
        return 0;
    }





  • 相关阅读:
    Spring Boot 2.3.0 正式发布!
    当互联网码农遇见国企老同学
    GitHub发布重大更新,关系到所有程序员!
    开发者被要求向破解者道歉,竟揪出“阿里云假员工”,网友:这人有前科
    等了整整12年!Linux QQ 终于更新了!
    我的电脑不联网,很安全,黑客:你还有风扇呢
    grpc的简单用例 (golang实现)
    grpc的简单用例 (C++实现)
    redis键过期 (redis 2.6及以上)
    安装folly库以及folly的ConcurrentHashMap的简单使用
  • 原文地址:https://www.cnblogs.com/bryce1010/p/9387156.html
Copyright © 2011-2022 走看看