Codeforces Gym101502 E.The Architect Omar-find()函数
1.0 s
256 MB
standard input
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.
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.
For each test case, print a single integer that represents the maximum number of apartments that can be furnished by Omar
1
6
bedXs
kitchenSS1
kitchen2
bedXs
living12
livingh
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()函数的更多相关文章
- 『ACM C++』Virtual Judge | 两道基础题 - The Architect Omar && Malek and Summer Semester
这几天一直在宿舍跑PY模型,学校的ACM寒假集训我也没去成,来学校的时候已经18号了,突然加进去也就上一天然后排位赛了,没学什么就去打怕是要被虐成渣,今天开学前一天,看到最后有一场大的排位赛,就上去试 ...
- 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 ...
- Codeforces 906D Power Tower(欧拉函数 + 欧拉公式)
题目链接 Power Tower 题意 给定一个序列,每次给定$l, r$ 求$w_{l}^{w_{l+1}^{w_{l+2}^{...^{w_{r}}}}}$ 对m取模的值 根据这个公式 每次 ...
- 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 ...
- Codeforces Gym101502 J-取数博弈
还有J题,J题自己并不是,套的板子,大家写的都一样,因为大家都是套板子过的,贴一下代码,等学会了写一篇博客... J.Boxes Game 代码: 1 //J. Boxes Game-取数博弈-不会, ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 实验一 查看CPU和内存,用机器指令和汇编指令编程
(1):使用debug,将下面的程序段写入内存,逐条执行,观察每条指令执行后,CPU中相关寄存器中内存的变化. 机器码 汇编指令 b8 20 4e mov ax,4E20H 05 ...
- Linux系统自启动脚
只需编辑/etc/init.d/rc.local文件,在最后加上你的脚本即可. 比如:我已经编写了一个脚本shell.sh,存放在/home/mars704/Desktop/ 下面在终端输入 gedi ...
- 15,scrapy中selenium的应用
引入 在通过scrapy框架进行某些网站数据爬取的时候,往往会碰到页面动态数据加载的情况发生如果直接用scrapy对其url发请求,是获取不到那部分动态加载出来的数据值,但是通过观察会发现,通过浏览器 ...
- 4 Template层 -定义模板
1.模板介绍 作为Web框架,Django提供了模板,可以很便利的动态生成HTML 模版系统致力于表达外观,而不是程序逻辑 模板的设计实现了业务逻辑(view)与显示内容(template)的分离,一 ...
- 在 Amazon AWS 搭建及部署网站:(二)安装、配置软件,启动网站
现在,我们已经有了一台EC2主机,具备了基本的硬件环境.下面,开始软件环境的配置. 第一步:连接服务器 后面所有的一切,都需要在SSH终端窗口操作.首先,我们需要一个SSH客户端.PuTTY是很常用的 ...
- Excel动画教程50例(三)
Excel动画教程50例(三) 31.Excel自定输入数据下拉列表 32.Excel正确输入身份证号码 33.Excel数据排序操作 34.Excel数据表格中如何将姓名信息按笔画排列 35.Exc ...
- uReplicator实现分析
MirrorMakerWorker分析 是整个同步机制的主入口,主要组织的逻辑有: 配置数据的传入与处理,ConsumerConfig对象的构建 度量对象的准备,定时上报的度量数据收集线程的定义与启动 ...
- 服务器(centos7)用nginx挂出多个网站的配置
前提: 装好环境的centos7系统(其他版本也行),装好ngnix: 推荐:http://www.cnblogs.com/alsy/p/5296244.html 把你的项目上传到服务器上(可以用Xf ...
- THUSC2018 爆零记
没想到我还真能过这个...... 太玄学了= = 不过这直接导致我月考数学挂科,掉出年级前十= = 5.26 THU过了! 真是十分意外的惊喜啊$-\omega-$ 6.1 今天出发去帝都! 然而飞行 ...
- Python爬虫教程-21-xpath
本篇简单介绍 xpath 在python爬虫方面的使用,想要具体学习 xpath 可以到 w3school 查看 xpath 文档 Python爬虫教程-21-xpath 什么是 XPath? XPa ...