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;
}

2017 JUST Programming Contest 3.0 E. The Architect Omar的更多相关文章

  1. 2017 JUST Programming Contest 2.0 题解

    [题目链接] A - On The Way to Lucky Plaza 首先,$n>m$或$k>m$或$k>n$就无解. 设$p = \frac{A}{B}$,$ans = C_{ ...

  2. gym101532 2017 JUST Programming Contest 4.0

    台州学院ICPC赛前训练5 人生第一次ak,而且ak得还蛮快的,感谢队友带我飞 A 直接用claris的模板啊,他模板确实比较强大,其实就是因为更新的很快 #include<bits/stdc+ ...

  3. 2017 JUST Programming Contest 3.0 B. Linear Algebra Test

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

  4. 2017 JUST Programming Contest 3.0 I. Move Between Numbers

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

  5. 2017 JUST Programming Contest 3.0 D. Dice Game

    D. Dice Game time limit per test 1.0 s memory limit per test 256 MB input standard input output stan ...

  6. 2017 JUST Programming Contest 3.0 H. Eyad and Math

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

  7. 2017 JUST Programming Contest 3.0 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 i ...

  8. gym101343 2017 JUST Programming Contest 2.0

    A.On The Way to Lucky Plaza  (数论)题意:m个店 每个店可以买一个小球的概率为p       求恰好在第m个店买到k个小球的概率 题解:求在前m-1个店买k-1个球再*p ...

  9. 2017 JUST Programming Contest 2.0

    B. So You Think You Can Count? 设dp[i]表示以i为结尾的方案数,每个位置最多往前扫10位 #include<bits/stdc++.h> using na ...

随机推荐

  1. 解决java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException

    解决: 工程目录.settings\org.eclipse.wst.common.project.facet.core.xml文件中jst.web的version降低到2.5 <?xml ver ...

  2. 深入浅出Redis(三)高级特性:管道

    Redis是一个响应式的服务,当client发送一个请求后,就处于堵塞状态等待Redis返回结果. 这样一次命令消耗的时间就包含三个部分:请求从client到server的时间.结果从server到c ...

  3. js实现的美女瀑布流效果代码

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  4. Cleave js 使用

    1111111111111111 xxxxxx Cleave.js 键入时格式化< input />内容   信用卡号码格式 明确   美国运通:从34/37开始 34   签证:从4开始 ...

  5. PRD编写Axure内直接编辑

    流程&页面&交互&逻辑 功能点: 1,选项类 设置默认值. 2,输入文本类 设置最多最少字符数. 3,功能按钮,如提交.发布. 判断敏感词,如果有,则点击发布的时候,悬浮提醒“ ...

  6. POJ 1927 Area in Triangle(计算几何)

    Area in Triangle 博客原文地址:http://blog.csdn.net/xuechelingxiao/article/details/40707691 题目大意: 给你一个三角形的三 ...

  7. 基于Cocos2dx + box2d 实现的愤慨的小鸟Demo

    1. Demo初始界面 2. 游戏界面 3. 精确碰撞检測 4. 下载  压缩文件文件夹 AngryBird source    愤慨的小鸟Demo源码,基于Cocos2dx C++,以及box2d技 ...

  8. 自己写的Android端HttpUtil工具类

    package com.sxt.jcjd.util; import java.io.IOException; import java.io.UnsupportedEncodingException; ...

  9. openxml in sql server

    OPENXML (Transact-SQL) OPENXML provides a rowset view over an XML document. Because OPENXML is a row ...

  10. 网站图片增强JS插件2.0(兼容IE&FF)

    网站图片增强JS插件2.0简单介绍:插件可以增强网站互动能力与外链建设,用户在欣赏图片的同时,把看好的图片直接制作成自己喜欢的样式后通过QQ等传播,增强外链建设,通过用户互动创造外链.(支持:放大缩小 ...