Submission #909403

# Submission time Handle Problem Language Result Execution time Memory
909403 2024-01-17T07:50:06 Z shoryu386 Hacker (BOI15_hac) C++17
100 / 100
435 ms 46140 KB
#include <bits/stdc++.h>
using namespace std;
#define MAX 200007
#define int long long
main(){
	int n; cin >> n;
	
	int count = (n+1)/2;
	
	int arr[2*n];
	for (int x = 0; x < n; x++) cin >> arr[x];
	for (int x = 0; x < n; x++) arr[n + x] = arr[x];
	
	int psum[2*n];
	psum[0] = arr[0];
	for (int x = 1; x < 2*n; x++) psum[x] = psum[x-1] + arr[x];
	
	#define rq(a, b) ((a==0) ? psum[b] : psum[b] - psum[a-1])
	
	int hmm[2*n]; memset(hmm, 63, sizeof(hmm));
	int sums[2*n];
	for (int x = 0; x < 2*n; x++){
		int sum = rq(x, x+count-1);
		sums[x] = sum;
	}
	
	multiset<int> ms;
	for (int x = 0; x < count; x++){
		ms.insert(sums[x]);
	}
	
	memset(hmm, -63, sizeof(hmm));
	hmm[0] = *ms.begin();
	
	for (int x = 1; x < n; x++){
		ms.insert(sums[count+x-1]);
		ms.erase(ms.find(sums[x-1]));
		
		hmm[x] = *ms.begin();
	}
	
	int ans = INT_MIN;
	for (int x = 0; x < n; x++){
		ans = max(ans, hmm[x]);
	}
	cout << ans;
}

Compilation message

hac.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 856 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 2 ms 856 KB Output is correct
31 Correct 2 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 36 ms 7260 KB Output is correct
5 Correct 99 ms 18256 KB Output is correct
6 Correct 151 ms 22868 KB Output is correct
7 Correct 154 ms 27600 KB Output is correct
8 Correct 313 ms 45632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 856 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 2 ms 856 KB Output is correct
31 Correct 2 ms 856 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 36 ms 7260 KB Output is correct
36 Correct 99 ms 18256 KB Output is correct
37 Correct 151 ms 22868 KB Output is correct
38 Correct 154 ms 27600 KB Output is correct
39 Correct 313 ms 45632 KB Output is correct
40 Correct 5 ms 1116 KB Output is correct
41 Correct 9 ms 2140 KB Output is correct
42 Correct 13 ms 2908 KB Output is correct
43 Correct 102 ms 18388 KB Output is correct
44 Correct 346 ms 45604 KB Output is correct
45 Correct 44 ms 9296 KB Output is correct
46 Correct 149 ms 27420 KB Output is correct
47 Correct 435 ms 45592 KB Output is correct
48 Correct 263 ms 46140 KB Output is correct
49 Correct 227 ms 44880 KB Output is correct
50 Correct 226 ms 45032 KB Output is correct