题目链接:https://ac.nowcoder.com/acm/contest/38305/E
思路:
读入一段时间,这个时间段的数值都加1,最后数值最大的就是数就是答案
代码:
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
const int N = 86400 + 10;
int s[N];
int main() {
int n;
scanf("%d", &n);
while(n --) {
int a, b, c, d, e, f;
scanf("%d:%d:%d - %d:%d:%d", &a, &b, &c, &d, &e, &f);
s[(a * 60 + b) * 60 + c] ++;
s[(d * 60 + e) * 60 + f + 1] --;
}
int maxn = -1;
for(int i = 1; i <= 86410; i ++) {
s[i] += s[i - 1];
maxn = max(maxn, s[i]);
}
printf("%d", maxn);
return 0;
}