Codeforces Round #147 (Div. 2) A. Free Cash
来源:互联网 发布:科比2010年总决赛数据 编辑:程序博客网 时间:2024/05/17 00:05
点击打开题目链接
Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free cash, than he doesn't want to wait and leaves the cafe immediately.
Valera is very greedy, so he wants to serve all n customers next day (and get more profit). However, for that he needs to ensure that at each moment of time the number of working cashes is no less than the number of clients in the cafe.
Help Valera count the minimum number of cashes to work at his cafe next day, so that they can serve all visitors.
The first line contains a single integer n (1 ≤ n ≤ 105), that is the number of cafe visitors.
Each of the following n lines has two space-separated integers hi and mi (0 ≤ hi ≤ 23; 0 ≤ mi ≤ 59), representing the time when the i-th person comes into the cafe.
Note that the time is given in the chronological order. All time is given within one 24-hour period.
Print a single integer — the minimum number of cashes, needed to serve all clients next day.
48 08 108 108 45
2
30 1210 1122 22
1
In the first sample it is not enough one cash to serve all clients, because two visitors will come into cafe in 8:10. Therefore, if there will be one cash in cafe, then one customer will be served by it, and another one will not wait and will go away.
In the second sample all visitors will come in different times, so it will be enough one cash.
特别特别注意n=1的时候,就是因为这个数据,我的答案卡在57组数据上。
代码:
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;struct ss{ int h; int m;}p[100005];bool cmp(ss a,ss b) { if(a.h==b.h) return a.m<b.m; else return a.h<b.h; }int n,i,j,k; int main() { cin>>n; for(i=0;i<n;i++) scanf("%d%d",&p[i].h,&p[i].m);sort(p,p+n,cmp);int ans=1,max=0;for(i=1;i<n;i++) { if(p[i].h==p[i-1].h&&p[i].m==p[i-1].m) ans++; else ans=1; if(max<ans) max=ans; } if(n==1) { printf("1\n"); }else cout<<max<<endl; return 0; }
- <Codeforces Round #147 (Div. 2)>A. Free Cash(水题)
- Codeforces Round #147 (Div. 2) / 237A Free Cash (模拟)
- Codeforces Round #147 (Div. 2) A. Free Cash
- codeforces 237A Free Cash
- Codeforces Round #359 (Div. 2) A. Free Ice Cream
- Codeforces Round #359 (Div. 2) A. Free Ice Cream
- CodeForces - 237A Free Cash (水)
- Codeforces 237A Free Cash(水题吧)
- Codeforces Round #147 (Div. 2) A题
- 【Codeforces Round #398 (Div. 2)】Codeforces 767E Change-free
- A. Free Cash
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #172 (Div. 2) A题
- C++构造函数和析构函数是否可以为virtual?
- notify和notifyAll的一段代码分析
- NYOJ 17 最长单调递增子序列
- PHP 5.5 新特性
- 【CocoStudio游戏开发之一】制作多分辨率UI布局
- Codeforces Round #147 (Div. 2) A. Free Cash
- Hbase Java API详解
- struts2+spring+spring jdbc
- 深复制体验(3)
- Codeforces Round #137 (Div. 2)
- Java操作Hbase进行建表、删表以及对数据进行增删改查,条件查询
- 第6周作业2-IF语句大显身手之成绩判断Gradelf
- hdu 1010 Tempter of the Bone 搜索
- 钻孔时怎样避开墙内电线