zoukankan      html  css  js  c++  java
  • <Codeforces Round #147 (Div. 2)>A. Free Cash(水题)

    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:

     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 int t[24][60];
     5 
     6 int main()
     7 {
     8     int h, m, n, max;
     9     while(scanf("%d", &n) != EOF)
    10     {
    11         max = 0;
    12         memset(t, 0, sizeof(t));
    13         while(n--)
    14         {
    15             scanf("%d %d", &h, &m);
    16             t[h][m]++;
    17         }
    18         for(int i = 0; i < 24; i++)
    19             for(int j = 0; j < 60; j++)
    20                 if(max < t[i][j])
    21                     max = t[i][j];
    22         printf("%d\n", max);
    23     }
    24     return 0;
    25 }



  • 相关阅读:
    Python any()
    从 SQL Server 到 MySQL (一):异构数据库迁移
    sql server作业实现数据同步
    分布式异构系统的数据一致性架构实现
    实战:sqlserver 数据实时同步到mysql
    基于MySQL的高可用准实时的数据同步方案
    SQL Server数据同步的研究(单向/双向)
    YY 数据库平台化建设实践
    两台SqlServer数据同步解决方案
    热迁移、异构数据库迁移、传输性能 这些上云的难题阿里云都帮你解决了
  • 原文地址:https://www.cnblogs.com/cszlg/p/2910450.html
Copyright © 2011-2022 走看看