其他分享
首页 > 其他分享> > Free Cash CodeForces - 237A

Free Cash CodeForces - 237A

作者:互联网

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.
题意
一个服务员在一个时间只能服务一位顾客。输入所有顾客来的时间,按时间顺序排序。求最小的服务员数。

思路
求出现重复的时间的最大重复次数。注意边界!

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct node
{
    int x,y;
};
node a[100005];
int v[100005];
int main()
{
    int n;
    while(cin>>n&&n!=0)
    {
        memset(v,0,sizeof(v));
        int sum,maxn=-1;
        for(int i=0;i<n;i++)
        {
            cin>>a[i].x>>a[i].y;
        }
        for(int i=0;i<n;i++)
        {
            sum=0;
            if(v[i]!=1)
            {
                for(int j=0;j<n;j++)
                {
                    if(a[i].x==a[j].x&&a[i].y==a[j].y)
                    {
                        v[j]=1;
                        sum++;
                    }
                }
            }
            maxn=max(maxn,sum);
        }
        cout<<maxn<<endl;
    }
    return 0;
}

标签:number,int,serve,237A,Free,Cash,will,time,cafe
来源: https://blog.csdn.net/weixin_44641254/article/details/104739696