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

这个题水题,用find()写。

代码:

 1 //E. The Architect Omar-find函数
2 #include<iostream>
3 #include<cstring>
4 #include<cstdio>
5 #include<queue>
6 #include<algorithm>
7 #include<cmath>
8 using namespace std;
9 int main(){
10 int t,n;
11 scanf("%d",&t);
12 while(t--){
13 scanf("%d",&n);
14 int num1=0,num2=0,num3=0;
15 for(int i=0;i<n;i++){
16 string s;
17 cin>>s;
18 if(s.find("bed")==0)num1++;
19 if(s.find("kitchen")==0)num2++;
20 if(s.find("living")==0)num3++;
21 }
22 //cout<<num1<<" "<<num2<<" "<<num3<<endl;
23 int ans=min(num1/2,min(num2,num3));
24 printf("%d\n",ans);
25 }
26 return 0;
27 }

Codeforces Gym101502 E.The Architect Omar-find()函数的更多相关文章

  1. 『ACM C++』Virtual Judge | 两道基础题 - The Architect Omar && Malek and Summer Semester

    这几天一直在宿舍跑PY模型,学校的ACM寒假集训我也没去成,来学校的时候已经18号了,突然加进去也就上一天然后排位赛了,没学什么就去打怕是要被虐成渣,今天开学前一天,看到最后有一场大的排位赛,就上去试 ...

  2. 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 ou ...

  3. Codeforces 906D Power Tower(欧拉函数 + 欧拉公式)

    题目链接  Power Tower 题意  给定一个序列,每次给定$l, r$ 求$w_{l}^{w_{l+1}^{w_{l+2}^{...^{w_{r}}}}}$  对m取模的值 根据这个公式 每次 ...

  4. Codeforces Gym101502 K.Malek and Summer Semester

    K. Malek and Summer Semester   time limit per test 1.0 s memory limit per test 256 MB input standard ...

  5. Codeforces Gym101502 J-取数博弈

    还有J题,J题自己并不是,套的板子,大家写的都一样,因为大家都是套板子过的,贴一下代码,等学会了写一篇博客... J.Boxes Game 代码: 1 //J. Boxes Game-取数博弈-不会, ...

  6. Codeforces Gym101502 I.Move Between Numbers-最短路(Dijkstra优先队列版和数组版)

    I. Move Between Numbers   time limit per test 2.0 s memory limit per test 256 MB input standard inpu ...

  7. Codeforces Gym101502 H.Eyad and Math-换底公式

    H. Eyad and Math   time limit per test 2.0 s memory limit per test 256 MB input standard input outpu ...

  8. Codeforces Gym101502 F.Building Numbers-前缀和

    F. Building Numbers   time limit per test 3.0 s memory limit per test 256 MB input standard input ou ...

  9. Codeforces Gym101502 B.Linear Algebra Test-STL(map)

    B. Linear Algebra Test   time limit per test 3.0 s memory limit per test 256 MB input standard input ...

随机推荐

  1. UVA - 753 A Plug for UNIX(网络流)

    题意 给定一些插头设备和插座,有一些方法可以把其中一些插头变成另一种插头.求无法匹配插座的插头设备个数. 题解 用\(map\)给每个字符串标号为\(a_i\)和\(b_i\). 读入每种改变插头的方 ...

  2. 并查集:HDU1213-How Many Tables(并查集最简单的应用)

    How Many Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...

  3. 扩展MarkDown表格

    一直不知道表格中的:是什么意思,看了GcsSloop的这篇文章后恍然大悟,做下记录. 原文链接 第二行分割线部分可以使用 : 来控制内容状态 MarkDown : | 默认 | 靠右 | 居中 | 靠 ...

  4. Struts1 部分源码学习

    Struts1工作原理    1.系统初始化(读取配置):初始化ModuleConfig对象       Struts框架是一个总控制器(ActionServlet)是一个Servlet,在web.x ...

  5. 63、加速android应用(转载)

    本文转自 http://www.devtf.cn/?p=1097 原文链接 : Speed up your app原文作者 : UDI COHEN译文出自 : 开发技术前线 www.devtf.cn. ...

  6. 线段树&树状数组模板

    树状数组: #include <bits/stdc++.h> using namespace std; ; struct binit { int a[MAXN], n; void modi ...

  7. BMP图片的加载方式:资源 VS 文件

    在程序中加载位图有很多方法,各有各的好处.这里简单说一下在资源里和文件里加载的区别. 第一.在资源里加载位图 这种方法就是在工程里的“资源视图”-->“添加资源”-->"Bitm ...

  8. linux环境搭建系列之memcached安装步骤

    1.从官网在线下载最新的安装包 wget http://memcached.org/downloads/memcached-1.4.34.tar.gz 该命令为在线下载 注意:最新的地址会变动,所以最 ...

  9. zookeeper 下载安装

    下载:wget https://www-us.apache.org/dist/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz 解压:tar -zx ...

  10. aspx页面直接访问后台方法

    在方法上面机上[WebMethod]就可以直接请求该方法了.