zoukankan      html  css  js  c++  java
  • BestCoder Round #2 1001 (简单处理)

    题目链接

    题意:给N条信息,每个信息代表有x个人从开始的时间 到 结束的时间在餐厅就餐,

    问最少需要多少座位才能满足需要。

    分析:由于时间只有24*60 所以把每个时间点放到 数组a中,并标记开始的时间+x,

    结束的时间 -x。最后累加比较。

    如果时间点太多的时候可以把时间点放到结构体里,排序,然后依次枚举结构体。

     1 #include <iostream>
     2 #include <cstring>
     3 #include <cstdlib>
     4 #include <cmath>
     5 #include <cstdio>
     6 #include <vector>
     7 #include <algorithm>
     8 #define LL long long
     9 #define rep(i, a, b)for(int i = a; i < b; i++)
    10 const int maxn = 1500+10;
    11 
    12 using namespace std;
    13 int a[maxn];
    14 
    15 int main()
    16 {
    17     int t, n, x, h, m, ans;
    18     cin>>t;
    19     while(t--)
    20     {
    21         memset(a, 0, sizeof(a));
    22         cin>>n;
    23         while(n--)
    24         {
    25             scanf("%d %d:%d", &x, &h, &m);
    26             a[h*60+m] += x;
    27             scanf("%d:%d", &h, &m);
    28             a[h*60+m] -= x;
    29         }
    30         ans = 0;
    31         rep(i, 1, maxn-1)
    32         a[i] += a[i-1];
    33         rep(i, 0, maxn-1)
    34         if(a[i]>ans)
    35         ans = a[i];
    36         cout<<ans<<endl;
    37     }
    38 }
  • 相关阅读:
    POJ_2387_最短路
    HDU_3172_带权并查集
    Python_多线程1(创建线程,简单线程同步)
    POJ_3013_最短路
    codeforces_725C_字符串
    python_文件io
    codeforces_731D_(前缀和)(树状数组)
    codeforces_738D
    java反射机制
    struts2入门
  • 原文地址:https://www.cnblogs.com/bfshm/p/3873593.html
Copyright © 2011-2022 走看看