Submission #1097930

# Submission time Handle Problem Language Result Execution time Memory
1097930 2024-10-08T16:17:49 Z Newtonabc Art Exhibition (JOI18_art) C++14
100 / 100
384 ms 25000 KB
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
const int N=5e5+10;
long long dp[N];
vector<pair<long long,long long> > v;
int main(){
	int n,st=0;
	long long cur=0;
	cin>>n;
	for(int i=0;i<n;i++){
		long long a,b;
		cin>>a >>b;
		v.push_back(mp(a,b));
	}
	long long val=-1e18,ans=LLONG_MIN;
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		dp[i]=max(0LL,val-v[i].first)+v[i].second;
		val=max(val,v[i].first)+v[i].second;
		ans=max(ans,dp[i]);
	}
	cout<<ans;
	
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:8:8: warning: unused variable 'st' [-Wunused-variable]
    8 |  int n,st=0;
      |        ^~
art.cpp:9:12: warning: unused variable 'cur' [-Wunused-variable]
    9 |  long long cur=0;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 444 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 444 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 4 ms 576 KB Output is correct
28 Correct 4 ms 780 KB Output is correct
29 Correct 4 ms 604 KB Output is correct
30 Correct 4 ms 692 KB Output is correct
31 Correct 4 ms 708 KB Output is correct
32 Correct 4 ms 604 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 5 ms 604 KB Output is correct
35 Correct 5 ms 600 KB Output is correct
36 Correct 4 ms 704 KB Output is correct
37 Correct 4 ms 604 KB Output is correct
38 Correct 4 ms 580 KB Output is correct
39 Correct 6 ms 572 KB Output is correct
40 Correct 4 ms 620 KB Output is correct
41 Correct 4 ms 604 KB Output is correct
42 Correct 3 ms 724 KB Output is correct
43 Correct 4 ms 604 KB Output is correct
44 Correct 7 ms 600 KB Output is correct
45 Correct 4 ms 604 KB Output is correct
46 Correct 4 ms 784 KB Output is correct
47 Correct 4 ms 604 KB Output is correct
48 Correct 4 ms 576 KB Output is correct
49 Correct 4 ms 700 KB Output is correct
50 Correct 4 ms 604 KB Output is correct
51 Correct 4 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 444 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 4 ms 576 KB Output is correct
28 Correct 4 ms 780 KB Output is correct
29 Correct 4 ms 604 KB Output is correct
30 Correct 4 ms 692 KB Output is correct
31 Correct 4 ms 708 KB Output is correct
32 Correct 4 ms 604 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 5 ms 604 KB Output is correct
35 Correct 5 ms 600 KB Output is correct
36 Correct 4 ms 704 KB Output is correct
37 Correct 4 ms 604 KB Output is correct
38 Correct 4 ms 580 KB Output is correct
39 Correct 6 ms 572 KB Output is correct
40 Correct 4 ms 620 KB Output is correct
41 Correct 4 ms 604 KB Output is correct
42 Correct 3 ms 724 KB Output is correct
43 Correct 4 ms 604 KB Output is correct
44 Correct 7 ms 600 KB Output is correct
45 Correct 4 ms 604 KB Output is correct
46 Correct 4 ms 784 KB Output is correct
47 Correct 4 ms 604 KB Output is correct
48 Correct 4 ms 576 KB Output is correct
49 Correct 4 ms 700 KB Output is correct
50 Correct 4 ms 604 KB Output is correct
51 Correct 4 ms 856 KB Output is correct
52 Correct 352 ms 24672 KB Output is correct
53 Correct 344 ms 24856 KB Output is correct
54 Correct 347 ms 25000 KB Output is correct
55 Correct 356 ms 24744 KB Output is correct
56 Correct 360 ms 24748 KB Output is correct
57 Correct 384 ms 24724 KB Output is correct
58 Correct 345 ms 24744 KB Output is correct
59 Correct 344 ms 24748 KB Output is correct
60 Correct 367 ms 24748 KB Output is correct
61 Correct 339 ms 24612 KB Output is correct
62 Correct 375 ms 24744 KB Output is correct
63 Correct 347 ms 24744 KB Output is correct
64 Correct 378 ms 24748 KB Output is correct
65 Correct 345 ms 24788 KB Output is correct
66 Correct 340 ms 24836 KB Output is correct
67 Correct 320 ms 24840 KB Output is correct
68 Correct 333 ms 24748 KB Output is correct