显示代码纯文本
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
struct node {
int t;
string c;
int d;
};
node s[10001];
int cmp(node x,node y)
{
if(x.t<y.t)
return 1;
if(x.t>y.t)
return 0;
if(x.t==y.t)
{
if(x.c<y.c)
return 1;
if(x.c>y.c)
return 0;
}
}
int work()
{
freopen("hey.in","r",stdin);
freopen("hey.out","w",stdout);
std::cout.sync_with_stdio(false);
int n;
cin>>n;
int i;
for(i=1;i<=n;i++)
cin>>s[i].t>>s[i].c>>s[i].d;
sort(s+1,s+n+1,cmp);
int t=0;
for(i=1;i<=n;i++)
{
if(i==1)
t=s[i].t;
else
{
if(s[i].t>t)
t=s[i].t;
}
cout<<s[i].c<<" "<<"went out at time "<<t<<endl;
t+=s[i].d;
}
return 0;
}
int xuanliu=work();
int main()
{;}