赛后总结
L2-2
- 思路:
- 比赛的时候以为是区间合并,写完之后发现并不是,最后十分钟想到是活动安排,发现活动安排不会写
- 看了题解,竟然是差分,太神奇了
- 但是还是没太理解为啥找到最大重合的就可以了
#include <bits/stdc++.h>
//#define int long long
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
using namespace std;
int a[N];
signed main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i ++)
{
int hh, mm, ss;
scanf("%d:%d:%d", &hh, &mm, &ss);
int st = hh * 3600 + mm * 60 + ss;
scanf("%d:%d:%d", &hh, &mm, &ss);
int ed = hh * 3600 + mm * 60 + ss;
a[st] ++;
a[ed + 1] --;
}
int res = -1;
int all_time = 24 * 60 * 60;
for(int i = 0; i <= all_time; i ++)
{
a[i] = a[i - 1] + a[i];
res = max(res, a[i]);
}
cout << res << endl;
return 0;
}