Submission #718477

# Submission time Handle Problem Language Result Execution time Memory
718477 2023-04-04T07:34:52 Z shoryu386 Art Exhibition (JOI18_art) C++17
50 / 100
1000 ms 17304 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
main(){
	int n; cin >> n;
	pair<int, int> szVal[n];
	for (int x = 0; x < n; x++) cin >> szVal[x].first >> szVal[x].second;
	
	sort(szVal, szVal+n);
	
	int l = 0, r = 0;
	
	int psum[n]; psum[0] = szVal[0].second;
	for (int x = 1; x < n; x++) psum[x] = psum[x-1] + szVal[x].second;
	int ans = LONG_LONG_MIN;
	for (int x = 0; x < n; x++){
		for (int y = x; y < n; y++){
			int sm = psum[y] - (szVal[y].first - szVal[x].first);
			if (x != 0) sm -= psum[x-1];
			
			ans = max(ans, sm);
		}
	}
	cout << ans;
}

Compilation message

art.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
art.cpp: In function 'int main()':
art.cpp:11:6: warning: unused variable 'l' [-Wunused-variable]
   11 |  int l = 0, r = 0;
      |      ^
art.cpp:11:13: warning: unused variable 'r' [-Wunused-variable]
   11 |  int l = 0, r = 0;
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 22 ms 468 KB Output is correct
28 Correct 26 ms 480 KB Output is correct
29 Correct 20 ms 468 KB Output is correct
30 Correct 19 ms 468 KB Output is correct
31 Correct 19 ms 484 KB Output is correct
32 Correct 20 ms 532 KB Output is correct
33 Correct 21 ms 436 KB Output is correct
34 Correct 22 ms 512 KB Output is correct
35 Correct 21 ms 468 KB Output is correct
36 Correct 23 ms 468 KB Output is correct
37 Correct 20 ms 536 KB Output is correct
38 Correct 21 ms 440 KB Output is correct
39 Correct 19 ms 540 KB Output is correct
40 Correct 19 ms 468 KB Output is correct
41 Correct 18 ms 528 KB Output is correct
42 Correct 18 ms 468 KB Output is correct
43 Correct 19 ms 516 KB Output is correct
44 Correct 20 ms 492 KB Output is correct
45 Correct 23 ms 484 KB Output is correct
46 Correct 19 ms 468 KB Output is correct
47 Correct 19 ms 480 KB Output is correct
48 Correct 21 ms 468 KB Output is correct
49 Correct 19 ms 468 KB Output is correct
50 Correct 19 ms 468 KB Output is correct
51 Correct 19 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 22 ms 468 KB Output is correct
28 Correct 26 ms 480 KB Output is correct
29 Correct 20 ms 468 KB Output is correct
30 Correct 19 ms 468 KB Output is correct
31 Correct 19 ms 484 KB Output is correct
32 Correct 20 ms 532 KB Output is correct
33 Correct 21 ms 436 KB Output is correct
34 Correct 22 ms 512 KB Output is correct
35 Correct 21 ms 468 KB Output is correct
36 Correct 23 ms 468 KB Output is correct
37 Correct 20 ms 536 KB Output is correct
38 Correct 21 ms 440 KB Output is correct
39 Correct 19 ms 540 KB Output is correct
40 Correct 19 ms 468 KB Output is correct
41 Correct 18 ms 528 KB Output is correct
42 Correct 18 ms 468 KB Output is correct
43 Correct 19 ms 516 KB Output is correct
44 Correct 20 ms 492 KB Output is correct
45 Correct 23 ms 484 KB Output is correct
46 Correct 19 ms 468 KB Output is correct
47 Correct 19 ms 480 KB Output is correct
48 Correct 21 ms 468 KB Output is correct
49 Correct 19 ms 468 KB Output is correct
50 Correct 19 ms 468 KB Output is correct
51 Correct 19 ms 536 KB Output is correct
52 Execution timed out 1050 ms 17304 KB Time limit exceeded
53 Halted 0 ms 0 KB -