<Codeforces Round #147 (Div. 2)>A. Free Cash(水题)
2012-10-29 17:53
405 查看
A. Free Cash
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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.
Output
Print a single integer — the minimum number of cashes, needed to serve all clients next day.
Sample test(s)
input
output
input
output
Note
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.
AC Code:
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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.
Output
Print a single integer — the minimum number of cashes, needed to serve all clients next day.
Sample test(s)
input
4 8 0 8 10 8 10 8 45
output
2
input
3
0 1210 1122 22
output
1
Note
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.
AC Code:
#include <stdio.h> #include <string.h> int t[24][60]; int main() { int h, m, n, max; while(scanf("%d", &n) != EOF) { max = 0; memset(t, 0, sizeof(t)); while(n--) { scanf("%d %d", &h, &m); t[h][m]++; } for(int i = 0; i < 24; i++) for(int j = 0; j < 60; j++) if(max < t[i][j]) max = t[i][j]; printf("%d\n", max); } return 0; }
相关文章推荐
- <Codeforces Round #147 (Div. 2)>A. Free Cash(水题)
- css div标签必须用<div></div>关闭
- <div style=\'clear:both\'></div>
- <div+css页面布局课堂笔记>1---div+css对页面布局的优势
- <div+css页面布局课堂笔记>8---页面浮动设计
- <div class="clear"></div>
- <div>里用display:block有用么?
- <div>手绘页面布局(上下左右中)
- <div style="display:none">中更改的内容使用js无法获取
- <Codeforces Round #127 (Div. 1)> B. Guess That Car!(难题)
- 网页制作简单入门——用<div>设计简单模块
- <div+css页面布局课堂笔记>9---页面布局网站首页设计实例__1
- <div+css页面布局课堂笔记>2---页面布局的盒子模型
- <div>的背景被<body>的背景遮蔽了。。。。。
- <div>标签嵌套多层如何找准位置
- <-这是目录-> SRM div1 hard solutions(52)
- <<web>>div嵌套就是矩形的递归
- 利用<div>层 和<img>标签,实现一个图片两个动画效果
- <div+css页面布局课堂笔记>6---与盒子相关的CSS属性第三部分
- <div+css页面布局课堂笔记>3---页面布局的盒子模型(IE与其他浏览器区别)