A. Free Cash
A. Free Cash
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
Examples
input
4
8 0
8 10
8 10
8 45
output
2
input
3
0 12
10 11
22 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.
My Answer Code:
/*
Author:Albert Tesla Wizard
Time:2020/12/11 17:41
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,ans,a[24][60],h,m,Max;
cin>>n;
for(int i=0;i<24;i++)
for(int j=0;j<60;j++)a[i][j]=0;
for(int i=1;i<=n;i++)
{
cin>>h>>m;
a[h][m]++;
}
Max=a[0][0];
for(int i=0;i<24;i++)
for(int j=0;j<60;j++)
{
if(Max<a[i][j])Max=a[i][j];
}
cout<<Max<<'\n';
return 0;
}
本文地址:https://blog.csdn.net/AlberTesla/article/details/111048023
上一篇: KMP算法
推荐阅读
-
C# 使用Free Spire.Presentation 实现对PPT插入、编辑、删除表格
-
C# 使用Free Spire.Presentation 实现对PPT插入、编辑、删除表格
-
AE怎么使用Flicker Free视频去闪烁插件?
-
AE怎么使用Flicker Free视频去闪烁插件?
-
JSP FusionCharts Free显示图表 具体实现
-
linux free命令详解和使用实例(查看内存使用率)
-
Any Video Converter Free AVC视频转换器怎么使用?Any Video Converter Free图文使用
-
查看Linux下系统资源占用常用命令(top、free、uptime)
-
Linux常用系统管理命令(top、free、kill、df)
-
malloc,free,calloc,realloc函数