zoukankan      html  css  js  c++  java
  • 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
    Copy
    4
    8 0
    8 10
    8 10
    8 45
    output
    Copy
    2
    input
    Copy
    3
    0 12
    10 11
    22 22
    output
    Copy
    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<algorithm>
    #include<string.h>
    using namespace std;
    bool cmp(int a,int b)
    {
      return a>b;
    }
    int a[100005],vis[100005];
    int main()
    { 
      int n,h,m;
      while(cin>>n)
      {
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++)
        {
          cin>>h>>m;
          a[i]=h*60+m;
          vis[a[i]]++;;
        }
        sort(vis,vis+100000,cmp);
        cout<<vis[0]<<endl;
      }
      return 0;
    }
  • 相关阅读:
    【安全运维】在Windows平台利用sysmon进行安全分析
    【渗透测试】利用分块传输绕安全狗
    【渗透测试】如何获取目标网站真实IP
    【渗透测试】渗透测试常用在线工具
    【读书笔记】《互联网企业安全建设高级指南》6-17
    【安全运维】linux安全加固项目
    【安全运维】初识osquery
    【渗透测试】使用隧道模式访问目标数据库
    【企业安全】使用文件hash进行威胁分析
    【编程开发】python学习-判断是否是私网IP地址
  • 原文地址:https://www.cnblogs.com/-citywall123/p/9710811.html
Copyright © 2011-2022 走看看