比赛 20140414 评测结果 AWWTTTTTTT
题目名称 登机 最终得分 10
用户昵称 digital-T 运行时间 7.032 s
代码语言 C++ 内存使用 1.07 MiB
提交时间 2014-04-14 11:20:07
显示代码纯文本
#include<fstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int T,N;
class Cow
{
public:
	int place,stops,x;
};
vector <Cow> stack;
int delay[200010]={0};
int main()
{
	freopen("boarding.in","r",stdin);
	freopen("boarding.out","w",stdout);
	scanf("%d",&N);
	int p,t,x=1-N;
	for(int i=1;i<=N;i++)
	{
		scanf("%d%d",&p,&t);
		stack.push_back((Cow){p,t,x});
		x++;
	}
	T=0;
	Cow temp;
	while(!stack.empty())
	{
		temp=stack.back();
		stack.pop_back();
		int time_count=0-temp.x;
		for(int i=1;i<=temp.place;i++)
		{
			time_count++;
			if(delay[i]>=time_count)
				time_count=delay[i]+1;
		}
		delay[temp.place]=time_count+temp.stops;
		T=max(delay[temp.place],T);
	}
	printf("%d",T);
	return 0;
}