Submission #260503

# Submission time Handle Problem Language Result Execution time Memory
260503 2020-08-10T11:49:45 Z Bill_00 Art Exhibition (JOI18_art) C++14
100 / 100
296 ms 28796 KB
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,c,d) for(ll i=c;i<=d;i++)
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
//int h[200001],p[200001];
//int sum[100001];
//pair<ll,ll>p[100001];
//pair<ll,ll>p1[100001];
//string s;
string str(string x,int l,int r){
	string h;
	for(int i=l;i<=r;i++){
		h+=x[i];
	}
	return h;
}
ll res[500001],ans[500001];
pair<ll,ll>p[500001];
int main(){
	//int color[200001];
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	for(int i=1;i<=n;i++){
		ll a,b;
		cin >> a >> b;
		p[i]=mp(a,b);
	}
	sort(p+1,p+n+1);
	res[n]=0,ans[1]=0;
	for(int i=n-1;i>=1;i--){
		res[i]=max((ll)0,res[i+1])+p[i+1].ss-(p[i+1].ff-p[i].ff);
	}
	for(int i=2;i<=n;i++){
		ans[i]=max((ll)0,ans[i-1])+p[i-1].ss-(p[i].ff-p[i-1].ff);
	}
	ll hariu=-1e9;
	for(int i=1;i<=n;i++){
		ll k=p[i].ss;
		k+=max((ll)0,res[i]);
		k+=max((ll)0,ans[i]);
		hariu=max(hariu,k);
	}
	cout << hariu;
}	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 3 ms 640 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 3 ms 640 KB Output is correct
33 Correct 3 ms 640 KB Output is correct
34 Correct 3 ms 640 KB Output is correct
35 Correct 3 ms 640 KB Output is correct
36 Correct 3 ms 640 KB Output is correct
37 Correct 3 ms 640 KB Output is correct
38 Correct 3 ms 640 KB Output is correct
39 Correct 3 ms 640 KB Output is correct
40 Correct 3 ms 664 KB Output is correct
41 Correct 3 ms 640 KB Output is correct
42 Correct 3 ms 640 KB Output is correct
43 Correct 3 ms 640 KB Output is correct
44 Correct 4 ms 640 KB Output is correct
45 Correct 3 ms 768 KB Output is correct
46 Correct 3 ms 640 KB Output is correct
47 Correct 3 ms 640 KB Output is correct
48 Correct 3 ms 640 KB Output is correct
49 Correct 3 ms 640 KB Output is correct
50 Correct 4 ms 640 KB Output is correct
51 Correct 3 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 3 ms 640 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 3 ms 640 KB Output is correct
33 Correct 3 ms 640 KB Output is correct
34 Correct 3 ms 640 KB Output is correct
35 Correct 3 ms 640 KB Output is correct
36 Correct 3 ms 640 KB Output is correct
37 Correct 3 ms 640 KB Output is correct
38 Correct 3 ms 640 KB Output is correct
39 Correct 3 ms 640 KB Output is correct
40 Correct 3 ms 664 KB Output is correct
41 Correct 3 ms 640 KB Output is correct
42 Correct 3 ms 640 KB Output is correct
43 Correct 3 ms 640 KB Output is correct
44 Correct 4 ms 640 KB Output is correct
45 Correct 3 ms 768 KB Output is correct
46 Correct 3 ms 640 KB Output is correct
47 Correct 3 ms 640 KB Output is correct
48 Correct 3 ms 640 KB Output is correct
49 Correct 3 ms 640 KB Output is correct
50 Correct 4 ms 640 KB Output is correct
51 Correct 3 ms 640 KB Output is correct
52 Correct 240 ms 28624 KB Output is correct
53 Correct 241 ms 28796 KB Output is correct
54 Correct 243 ms 28672 KB Output is correct
55 Correct 242 ms 28664 KB Output is correct
56 Correct 243 ms 28664 KB Output is correct
57 Correct 240 ms 28664 KB Output is correct
58 Correct 240 ms 28664 KB Output is correct
59 Correct 245 ms 28664 KB Output is correct
60 Correct 238 ms 28664 KB Output is correct
61 Correct 296 ms 28664 KB Output is correct
62 Correct 237 ms 28664 KB Output is correct
63 Correct 237 ms 28792 KB Output is correct
64 Correct 240 ms 28792 KB Output is correct
65 Correct 263 ms 28664 KB Output is correct
66 Correct 276 ms 28664 KB Output is correct
67 Correct 274 ms 28668 KB Output is correct
68 Correct 240 ms 28664 KB Output is correct