codeforces 237A Free Cash

本文介绍了一个问题的解决方案,即如何计算一家24/7营业的快餐店为确保每位顾客都能被服务所需的最少收银台数量。通过分析顾客到达的时间点,文章提供了一种算法来确定高峰期同时到达的最大顾客数,进而得出所需收银台的数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

点击打开链接

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.

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<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[100010],b[100010],v[100010];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d%d",&a[i],&b[i]);
    memset(v,0,sizeof(v));
    int ma=1;
    for(int i=0;i<n;i++)
    {
        if(v[i])
            continue;
        int s=0;
        for(int j=0;j<n;j++)
        {
            if(a[i]==a[j]&&b[i]==b[j])
             {
                 s++;
                 v[j]=1;
             }
        }
        ma=max(ma,s);
    }
    printf("%d\n",ma);
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值