记录编号 96589 评测结果 AWATTTTTTT
题目名称 [USACO Feb14]登机 最终得分 20
用户昵称 GravatarOI永别 是否通过 未通过
代码语言 C++ 运行时间 7.021 s
提交时间 2014-04-14 11:42:54 内存使用 4.13 MiB
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
#define N 200010
struct arr{
	int s;
	long long t;
}cow[N];
int n;
long long ans[N] = {0}; 
inline int getint(){
	char ch;
	int x = 0;
	while (!isdigit(ch = getchar()));
	x = ch - 48;
	while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
	return x;
}

int main(){
	freopen("boarding.in","r",stdin);
	freopen("boarding.out","w",stdout);
	n = getint();	
	for (int i = 1; i <= n; i++){
		cow[i].s = getint();
		cow[i].t = getint();
	}
	for (int i = 1; i <= n; i++){
		ans[i] += cow[i].s + n - i;
		ans[i] += cow[i].t;
	}
	long long anss = 0;
	for (int i = 1; i <= n; i++){
		for (int j = n; j > i; j--){
			if (cow[i].s > cow[j].s) ans[i] += cow[j].t;		
		}
		anss = max(ans[i],anss);
	}
	printf("%I64d\n",anss);
	return 0;
}