比赛 20130725暑期B班1测 评测结果 AAAAWW
题目名称 黑叔 最终得分 66
用户昵称 日光。 运行时间 0.036 s
代码语言 C++ 内存使用 0.43 MiB
提交时间 2012-07-18 10:21:32
显示代码纯文本
#include<algorithm>
#include<iostream>
#include<string.h>
#include<fstream>
using namespace std;
struct node
{
	int Time,need;
	string name;
}number[10005];
bool cmp(node a,node b)
{
	if(a.Time==b.Time) return a.name<b.name;
	else return a.Time<b.Time;
}
int main()
{
	ifstream fin("hey.in");
	ofstream fout("hey.out");
	int n;
	fin>>n;
	for(int i=1;i<=n;i++)
	{
		fin>>number[i].Time>>number[i].name>>number[i].need;
	}
	sort(number+1,number+n+1,cmp);
	fout<<number[1].name<<" went out at time "<<number[1].Time<<endl;
	for(int i=2;i<=n;i++)
	{
		if(number[i].Time>(number[i-1].Time+number[i-1].need))
		{
			fout<<number[i].name<<" went out at time "<<number[i].Time<<endl;
		}
		else fout<<number[i].name<<" went out at time "<<(number[i-1].Time+number[i-1].need)<<endl;
	}
	return 0;
}