<Codeforces Round #147 (Div. 2)>A. Free Cash(水题)

本博客讨论了如何帮助快餐店老板Valera在一天内为所有顾客提供服务,确保任何时候在店内的顾客人数不超过可用的现金台数。通过分析顾客到达时间,计算出了所需的最少现金台数量。
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
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.

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;
}



(SCI三维路径规划对比)25年最新五种智能算法优化解决无人机路径巡检三维路径规划对比(灰雁算法真菌算法吕佩尔狐阳光生长研究(Matlab代码实现)内容概要:本文档主要介绍了一项关于无人机三维路径巡检规划的研究,通过对比2025年最新的五种智能优化算法(包括灰雁算法、真菌算法、吕佩尔狐算法、阳光生长算法等),在复杂三维环境中优化无人机巡检路径的技术方案。所有算法均通过Matlab代码实现,并重点围绕路径安全性、效率、能耗和避障能力进行性能对比分析,旨在为无人机在实际巡检任务中的路径规划提供科学依据和技术支持。文档还展示了多个相关科研方向的案例与代码资源,涵盖路径规划、智能优化、无人机控制等多个领域。; 适合人群:具备一定Matlab编程基础,从事无人机路径规划、智能优化算法研究或自动化、控制工程方向的研究生、科研人员及工程技术人员。; 使用场景及目标:① 对比分析新型智能算法在三维复杂环境下无人机路径规划的表现差异;② 为科研项目提供可复现的算法代码与实验基准;③ 支持无人机巡检、灾害监测、电力线路巡查等实际应用场景的路径优化需求; 阅读建议:建议结合文档提供的Matlab代码进行仿真实验,重点关注不同算法在收敛速度、路径长度和避障性能方面的表现差异,同时参考文中列举的其他研究案例拓展思路,提升科研创新能力。
### Codeforces Round 1005 Div. 2 A-F Problem Solutions #### A. Money Change 为了处理货币转换问,可以将所有的金额都转化为分的形式来简化计算。通过遍历输入数据并累加各个部分的金额,最后求得剩余的钱数并对100取模得到最终结果[^2]。 ```cpp #include <iostream> using namespace std; int main() { int s, xi, yi; cin >> s; int total_cents = 0; for (int i = 0; i < s; ++i) { cin >> xi >> yi; total_cents += xi * 100 + yi; } cout << (s * 100 - total_cents) % 100 << endl; } ``` #### B. Odd and Even Pairs 此目要求找到至少一对满足条件的索引:要么是一个偶数值的位置,或者是两个奇数值位置。程序会读入测试次数`t`以及每次测试中的数组长度`n`及其元素,并尝试找出符合条件的一对索引输出;如果没有这样的组合则返回-1[^3]。 ```cpp #include <cstdio> int main() { int t, n, num; scanf("%d", &t); while (t--) { int evenIndex = 0, oddIndex1 = 0, oddIndex2 = 0; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &num); if (num % 2 == 0 && !evenIndex) evenIndex = i; else if (num % 2 != 0) { if (!oddIndex1) oddIndex1 = i; else if (!oddIndex2) oddIndex2 = i; } if ((evenIndex || (oddIndex1 && oddIndex2))) break; } if (evenIndex) printf("1\n%d\n", evenIndex); else if (oddIndex1 && oddIndex2) printf("2\n%d %d\n", oddIndex1, oddIndex2); else printf("-1\n"); } return 0; } ``` 由于仅提供了前两道的具体描述和解决方案,在这里无法继续给出完整的C至F解答。通常情况下,每一道竞赛编程都有其独特的挑战性和解决方法,建议查阅官方解或社区讨论获取更多帮助。
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值