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.
思路:用map存一下,找到同一时间段出现的人的最大数量
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n,ans=0;
cin>>n;
map<pair<int,int>,int>mp;
for(int i=1;i<=n;i++)
{
int h,m;
cin>>h>>m;
mp[{h,m}]++;
}
for(auto it:mp)
{
ans=max(ans,it.second);
}
cout<<ans;
return 0;
}