답안 #66751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66751 2018-08-12T08:57:39 Z quoriess Art Exhibition (JOI18_art) C++14
100 / 100
883 ms 30440 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pii;
vector<pii> arts;
const int MAXN=5*1e5+5;
#define  boy first;
#define  value second;
int main(){
	int n;
	cin>>n;
	vector<lli> prefVal(n);

	lli ans=-10;
	for (int i = 0; i < n; i++)
	{
		pii a;
		cin>>a.first>>a.second;
		ans=max(ans,a.second);
		arts.push_back(a);
	}
	sort(arts.begin(),arts.end());
	vector<lli> minim(n,0),minimaxi(n,0);
	minimaxi[0]=minim[0]=arts[0].first;
	vector<lli> prefmin(n,0),prefminmax(n,0);
	prefminmax[0]=prefmin[0]=arts[0].first;

	for (int i = 0; i < n; i++)
	{
		pii a=arts[i];
		if(i==0)prefVal[0]=a.second;
		else prefVal[i]=prefVal[i-1]+a.second;
		if(i!=0){
			minim[i]=arts[i].first-arts[i-1].first-arts[i-1].second;
			minimaxi[i]=max(minimaxi[i-1],minim[i]);
			prefmin[i]=prefmin[i-1]+minim[i];
			prefminmax[i]=max(prefminmax[i-1],prefmin[i]);
		}
	}
	for (int i = 1; i < n; i++)
	{
		lli snc=prefVal[i]-arts[i].first+prefminmax[i];
		ans=max(snc,ans);
	}


	cout <<ans<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 4 ms 640 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 4 ms 640 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 3 ms 828 KB Output is correct
18 Correct 3 ms 828 KB Output is correct
19 Correct 3 ms 828 KB Output is correct
20 Correct 3 ms 828 KB Output is correct
21 Correct 3 ms 828 KB Output is correct
22 Correct 3 ms 828 KB Output is correct
23 Correct 3 ms 828 KB Output is correct
24 Correct 3 ms 828 KB Output is correct
25 Correct 4 ms 828 KB Output is correct
26 Correct 3 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 4 ms 640 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 3 ms 828 KB Output is correct
18 Correct 3 ms 828 KB Output is correct
19 Correct 3 ms 828 KB Output is correct
20 Correct 3 ms 828 KB Output is correct
21 Correct 3 ms 828 KB Output is correct
22 Correct 3 ms 828 KB Output is correct
23 Correct 3 ms 828 KB Output is correct
24 Correct 3 ms 828 KB Output is correct
25 Correct 4 ms 828 KB Output is correct
26 Correct 3 ms 828 KB Output is correct
27 Correct 11 ms 1168 KB Output is correct
28 Correct 11 ms 1296 KB Output is correct
29 Correct 9 ms 1424 KB Output is correct
30 Correct 15 ms 1552 KB Output is correct
31 Correct 15 ms 1676 KB Output is correct
32 Correct 11 ms 1808 KB Output is correct
33 Correct 11 ms 1936 KB Output is correct
34 Correct 11 ms 2064 KB Output is correct
35 Correct 11 ms 2192 KB Output is correct
36 Correct 9 ms 2320 KB Output is correct
37 Correct 11 ms 2448 KB Output is correct
38 Correct 11 ms 2576 KB Output is correct
39 Correct 10 ms 2752 KB Output is correct
40 Correct 11 ms 2832 KB Output is correct
41 Correct 12 ms 2960 KB Output is correct
42 Correct 10 ms 3084 KB Output is correct
43 Correct 10 ms 3212 KB Output is correct
44 Correct 11 ms 3212 KB Output is correct
45 Correct 9 ms 3212 KB Output is correct
46 Correct 9 ms 3212 KB Output is correct
47 Correct 11 ms 3212 KB Output is correct
48 Correct 10 ms 3212 KB Output is correct
49 Correct 13 ms 3212 KB Output is correct
50 Correct 10 ms 3212 KB Output is correct
51 Correct 10 ms 3212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 640 KB Output is correct
8 Correct 4 ms 640 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 3 ms 828 KB Output is correct
18 Correct 3 ms 828 KB Output is correct
19 Correct 3 ms 828 KB Output is correct
20 Correct 3 ms 828 KB Output is correct
21 Correct 3 ms 828 KB Output is correct
22 Correct 3 ms 828 KB Output is correct
23 Correct 3 ms 828 KB Output is correct
24 Correct 3 ms 828 KB Output is correct
25 Correct 4 ms 828 KB Output is correct
26 Correct 3 ms 828 KB Output is correct
27 Correct 11 ms 1168 KB Output is correct
28 Correct 11 ms 1296 KB Output is correct
29 Correct 9 ms 1424 KB Output is correct
30 Correct 15 ms 1552 KB Output is correct
31 Correct 15 ms 1676 KB Output is correct
32 Correct 11 ms 1808 KB Output is correct
33 Correct 11 ms 1936 KB Output is correct
34 Correct 11 ms 2064 KB Output is correct
35 Correct 11 ms 2192 KB Output is correct
36 Correct 9 ms 2320 KB Output is correct
37 Correct 11 ms 2448 KB Output is correct
38 Correct 11 ms 2576 KB Output is correct
39 Correct 10 ms 2752 KB Output is correct
40 Correct 11 ms 2832 KB Output is correct
41 Correct 12 ms 2960 KB Output is correct
42 Correct 10 ms 3084 KB Output is correct
43 Correct 10 ms 3212 KB Output is correct
44 Correct 11 ms 3212 KB Output is correct
45 Correct 9 ms 3212 KB Output is correct
46 Correct 9 ms 3212 KB Output is correct
47 Correct 11 ms 3212 KB Output is correct
48 Correct 10 ms 3212 KB Output is correct
49 Correct 13 ms 3212 KB Output is correct
50 Correct 10 ms 3212 KB Output is correct
51 Correct 10 ms 3212 KB Output is correct
52 Correct 883 ms 30440 KB Output is correct
53 Correct 833 ms 30440 KB Output is correct
54 Correct 727 ms 30440 KB Output is correct
55 Correct 739 ms 30440 KB Output is correct
56 Correct 724 ms 30440 KB Output is correct
57 Correct 726 ms 30440 KB Output is correct
58 Correct 725 ms 30440 KB Output is correct
59 Correct 810 ms 30440 KB Output is correct
60 Correct 795 ms 30440 KB Output is correct
61 Correct 730 ms 30440 KB Output is correct
62 Correct 744 ms 30440 KB Output is correct
63 Correct 787 ms 30440 KB Output is correct
64 Correct 765 ms 30440 KB Output is correct
65 Correct 722 ms 30440 KB Output is correct
66 Correct 759 ms 30440 KB Output is correct
67 Correct 804 ms 30440 KB Output is correct
68 Correct 799 ms 30440 KB Output is correct