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 ...
随机推荐
- Unity脚本执行顺序自研框架
本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/52372611 作者:car ...
- Java多线程-yield(),sleep()以及wait()的区别
从操作系统的角度讲,os会维护一个ready queue(就绪的线程队列).并且在某一时刻cpu只为ready queue中位于队列头部的线程服务.但是当前正在被服务的线程可能觉得cpu的服务质量不够 ...
- 【Remove Duplicates from Sorted Array】cpp
题目: https://leetcode.com/problems/remove-duplicates-from-sorted-array/ Given a sorted array, remove ...
- IOS开发学习笔记025-xib和storyboard
stotyboard : 描述软件界面,大范围,比较适合整个软件的所有界面 xib文件的使用:描述软件界面,小范围,比较适合描述小界面 在xcode新建文件窗口可以看到两个文件,storyboard和 ...
- hnust 土豪金的加密解密
问题 G: 土豪金的加密与解密 时间限制: 1 Sec 内存限制: 128 MB提交: 466 解决: 263[提交][状态][讨论版] 题目描述 有一位姓金的同学因为买了一部土豪金,从此 ...
- 解决This application failed to start because it could not find or load the Qt platform plugin "windows
解决方案:所在环境python根目录下qt.conf,重新设置path即可,此类问题通常在目录转移之后出现.
- unity c# 代码示例
1. using UnityEngine; using System.Collections; public class AnimatorMove : MonoBehaviour { public f ...
- jquery中attr和prop的区别介绍
在高版本的jquery引入prop方法后,什么时候该用prop?什么时候用attr?它们两个之间有什么区别?这些问题就出现了. 关于它们两个的区别,网上的答案很多.这里谈谈我的心得,我的心得很简单: ...
- PHP中create_function的用法总结
在php中,函数create_function主要用来创建匿名函数,有时候匿名函数可以发挥它的作用. 1.测试一 测试一主要用来循环替换数组中多个值的<与>,我们用array_map加上c ...
- CentOS7重新生成 /boot/grub2/grub.cfg
CentOS7重新生成 /boot/grub2/grub.cfg CentOS7 is using grub2 and the generated /boot/grub2/grub.cfg rathe ...