zoukankan      html  css  js  c++  java
  • Codeforces 237A

    题目链接: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.

    题解:取连续相同时间数量的最大值

     1 #include <iostream>
     2 #include <string>
     3 #include <cstring>
     4 #include <algorithm>
     5 #include <cmath>
     6 #include <map>
     7 #include <set>
     8 using namespace std;
     9 #define N 100010
    10 struct P
    11 {
    12     int h,m;
    13 }a[N];
    14 bool cmp(P x,P y){
    15     if(x.h==y.h) return x.m<y.m;
    16     else return x.h<y.h;
    17 }
    18 int main()
    19 {
    20     int n;
    21     while(cin>>n){
    22         for(int i=0;i<n;i++){
    23             cin>>a[i].h>>a[i].m;
    24         }
    25         sort(a,a+n,cmp);
    26         int t=1,s=1;
    27         for(int i=1;i<n;i++){
    28             if(a[i].h==a[i-1].h&&a[i].m==a[i-1].m){
    29                 s++;
    30                 if(s>t)t=s;
    31             }
    32             else s=1;
    33         }
    34         cout<<t<<endl;
    35     }
    36     return 0;
    37 }
  • 相关阅读:
    django页面分类和继承
    django前端从数据库获取请求参数
    pycharm配置django工程
    django 应用各个py文件代码
    CF. 1428G2. Lucky Numbers(背包DP 二进制优化 贪心)
    HDU. 6566. The Hanged Man(树形背包DP DFS序 重链剖分)
    小米邀请赛 决赛. B. Rikka with Maximum Segment Sum(分治 决策单调性)
    区间树 学习笔记
    CF GYM. 102861M. Machine Gun(主席树)
    2016-2017 ACM-ICPC East Central North America Regional Contest (ECNA 2016) (B, D, G, H)
  • 原文地址:https://www.cnblogs.com/shixinzei/p/7475346.html
Copyright © 2011-2022 走看看