枚举每一分钟。水题
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define INF 1e9
#define maxn 10000
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define mset(x) memset(x,0,sizeof(x))
typedef vector<int> vi;
int t, x[maxn], n, st[maxn],ed[maxn],hh,mm, time[24*60+10] ;
int main(){
// freopen("a.txt","r",stdin);
// freopen(".out","w",stdout);
cin>>t;
while(t--){
cin>>n;
int endt = 0, startt=INF;
rep(i,1,n){
scanf("%d %d:%d",&x[i],&hh,&mm);
st[i] = hh*60+mm;
scanf("%d:%d",&hh,&mm);
ed[i] = hh*60+mm;
endt = max(ed[i], endt);
startt = min(st[i], startt);
}
mset(time);
rep(i,1,n){
for(int j=st[i]; j<ed[i]; j++){
time[j] += x[i];
}
}
int ans=0;
rep(i,startt,endt){
ans = max(time[i],ans);
}
cout<<ans<<endl;
}
return 0;
}
/*
DESCRIPTION:
n组人,第i组有xi个人,在sti时到,在edi时离开
求同一时间的最少人数
*/