#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<map>
using namespace std;
struct students{
string s,ss;
int h,m,sec,t;
}a[10005];
int n,k,ans,cnt;
bool cmp(const students &x,const students &y)
{
return x.t<y.t;
}
bool cmp0(const students &x,const students &y)
{
return x.s<y.s;
}
map<string,bool>q;
map<string,int>last;
map<string,int>ti;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>a[i].s;
scanf("%d:%d:%d",&a[i].h,&a[i].m,&a[i].sec);
cin>>a[i].ss;
a[i].t=a[i].h*3600+a[i].m*60+a[i].sec;
}
sort(a+1,a+1+n,cmp);
cnt=n;
for(int i=1;i<=n;i++)
{
if(a[i].ss=="out")
{
if(q[a[i].s])
{
q[a[i].s]=0;
ans--;
ti[a[i].s]+=a[i].t-a[last[a[i].s]].t;
last[a[i].s]=0;
}
else{
a[i].t=1e9;
cnt--;
}
}
else{
if(q[a[i].s])
{
a[last[a[i].s]].t=1e9;
cnt--;
}
else{
q[a[i].s]=1;
ans++;
}
last[a[i].s]=i;
}
}
map<string,bool>::iterator it;
for(it=q.begin();it!=q.end();it++)
{
if(it->second==1)
{
a[last[it->first]].t=1e9;
cnt--;
}
}
sort(a+1,a+1+n,cmp);
int j=1;
ans=0;
for(int i=1,h,m,s;i<=k;i++)
{
scanf("%d:%d:%d",&h,&m,&s);
int t=h*3600+m*60+s;
while(t>=a[j].t&&j<=n)
{
if(a[j].ss=="in")
ans++;
else
ans--;
j++;
}
cout<<ans<<endl;
}
queue<string>q0;
int mx=0;
sort(a+1,a+1+n,cmp0);
for(int i=1;i<=n;i++)
{
if(a[i].s!=a[i-1].s)
{
if(ti[a[i].s]==mx)
q0.push(a[i].s);
if(ti[a[i].s]>mx)
{
mx=ti[a[i].s];
while(!q0.empty())
q0.pop();
q0.push(a[i].s);
}
}
}
while(!q0.empty())
{
string ac=q0.front();
q0.pop();
cout<<ac<<' ';
}
int h0=mx/3600;
mx%=3600;
int m0=mx/60;
mx%=60;
printf("%02d:%02d:%02d",h0,m0,mx);
return 0;
}
7-23 扫码抗疫情
最新推荐文章于 2024-08-30 21:09:25 发布