题目链接:http://codeforces.com/problemset/problem/237/A

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 <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define N 100010
struct P
{
int h,m;
}a[N];
bool cmp(P x,P y){
if(x.h==y.h) return x.m<y.m;
else return x.h<y.h;
}
int main()
{
int n;
while(cin>>n){
for(int i=;i<n;i++){
cin>>a[i].h>>a[i].m;
}
sort(a,a+n,cmp);
int t=,s=;
for(int i=;i<n;i++){
if(a[i].h==a[i-].h&&a[i].m==a[i-].m){
s++;
if(s>t)t=s;
}
else s=;
}
cout<<t<<endl;
}
return ;
}

Codeforces 237A - Free Cash的更多相关文章

  1. codeforces Gym 100500C D.Hall of Fame 排序

    Hall of Fame Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachmen ...

  2. CodeForces Round #548 Div2

    http://codeforces.com/contest/1139 A. Even Substrings You are given a string s=s1s2…sns=s1s2…sn of l ...

  3. 【Codeforces 115D】Unambiguous Arithmetic Expression

    Codeforces 115 D 题意:给一个没有括号的表达式,问有多少种添加括号的方法使得这是一个合法的表达式?输入可能有正负号.加减乘除.数字. 思路1: 这是不能过的\(naive\)的\(dp ...

  4. CodeForces 867B Save the problem

    B. Save the problem! http://codeforces.com/contest/867/problem/B time limit per test 2 seconds memor ...

  5. Codeforces Round VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM 暴力出奇迹!

    VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM Time Lim ...

  6. Codeforces Gym100812 L. Knights without Fear and Reproach-扩展欧几里得(exgcd)

    补一篇以前的扩展欧几里得的题,发现以前写错了竟然也过了,可能数据水??? 这个题还是很有意思的,和队友吵了两天,一边吵一边发现问题??? L. Knights without Fear and Rep ...

  7. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  8. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  9. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

随机推荐

  1. Tensorflow安装记录

    一.安装Ubantu环境 下载ios 网址:http://cn.ubuntu.com/download/ 2.配合虚拟机进行安装环境 虚拟机直接百度下载即可 虚拟机采用 具体安装,虚拟机百度中很多记录 ...

  2. 怎样打开U盘最安全

    为了避免电脑使用U盘时,通过双击,或者右击盘符时,导致把病毒感染至整个电脑,因此使用下面的方法,可使U盘病毒不被激活传播. 在取消了U盘自动运行的情况下(在组策略中一定要关闭自动运行功能,否则只要一插 ...

  3. Linux个人知识扩展:服务器几u的意思,网络带宽

    服务器几u的意思: 指的服务器大小规格 1U=4.45cm 2U=8.9cm 3U=4.45cm * 3 4U=4.45cm * 4 这指的是服务器的高度 现在的服务器为节省空间都是很扁的 U是服务器 ...

  4. Java通过sftp上传文件

    Linux操作系统我们经常使用ssh中的ftp,sftp连接服务器,做相应操作. 如何通过java代码的形式采用sftp连接到服务器,进行文件上传下载等操作呢? 第一步,引入依赖包 <!-- s ...

  5. daofu

    快排排序算法 public class QuickSort { public static void Main(String[] args) { , , , , , , , }; quickSort( ...

  6. 解放你生产力的10款效率工具,赶紧mark起来

    聪明的人总是善用工具 社会的快度发展赋予我们的一个幸运之处在于:你可以通过读书或使用工具去改善自身的处境甚至是阶层. 在父母那个时代,通过熟练使用办公软件,可以使一个在水泥地做帮工的青年走进格子间.而 ...

  7. Mybatis select、insert、update、delete 增删改查操作

    MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架. MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设置以及对结果集的检索.MyBatis 可以使用简单的XML ...

  8. Docker ssh server

    这个话题真让我气愤啊,在家里的mac上我已经全部摆平了,结果在公司的Linux上就给堵住了 原因不祥,但最后在错误提示里,有个移除(remove)信息,我照做了,就没问题了,全通了 大概是linux里 ...

  9. centos make error: fatal error: curses.h: No such file or directory

    yum install ncurses.x86_64 yum install ncurses-devel.x86_64 yum install ncurses-libs.x86_64 yum inst ...

  10. svn中给个地址,然后把自己建立的项目拖进去

    1.首先checkout 那个地址就会得到一个空的文件夹(里面有.svn文件) 2.把你的项目copy一下,粘贴到你chekout的文件夹里面,所有文件都是?,然后选中全部,点击add,然后在comm ...