Submission #47075

# Submission time Handle Problem Language Result Execution time Memory
47075 2018-04-27T09:27:46 Z Bruteforceman Hacker (BOI15_hac) C++11
100 / 100
85 ms 28976 KB
#include "bits/stdc++.h"
using namespace std;
int n;
int a[500010];
long long p[500010];
const long long inf = 1e17;

int main(int argc, char const *argv[])
{
	ios_base :: sync_with_stdio (false);
	cin.tie (0);
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int move = (n + 1) >> 1;
	long long sum = 0;
	for(int i = 0; i < move; i++) {
		sum += a[i];
	}
	for(int i = 0; i < n; i++) {
		p[i] = sum;
		sum -= a[i];
		sum += a[(i + move) % n];
	}
	long long ans = 0;
	deque <pair <long long, int>> Q;
	for(int i = 0; i < move; i++) {
		while(!Q.empty() && Q.back().first >= p[i]) {
			Q.pop_back();
		}
		Q.push_back(make_pair(p[i], i));
	}
	for(int i = 0; i < n; i++) {
		ans = max(ans, Q.front().first);
		if(Q.front().second == i) {
			Q.pop_front();
		}
		int id = (i + move) % n;
		while(!Q.empty() && Q.back().first >= p[id]) {
			Q.pop_back();
		}
		Q.push_back(make_pair(p[id], id));
	}
	cout << ans << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 400 KB Output is correct
3 Correct 3 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 2 ms 704 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 2 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 704 KB Output is correct
15 Correct 2 ms 704 KB Output is correct
16 Correct 2 ms 704 KB Output is correct
17 Correct 2 ms 704 KB Output is correct
18 Correct 2 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 400 KB Output is correct
3 Correct 3 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 2 ms 704 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 2 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 704 KB Output is correct
15 Correct 2 ms 704 KB Output is correct
16 Correct 2 ms 704 KB Output is correct
17 Correct 2 ms 704 KB Output is correct
18 Correct 2 ms 704 KB Output is correct
19 Correct 2 ms 704 KB Output is correct
20 Correct 2 ms 704 KB Output is correct
21 Correct 2 ms 704 KB Output is correct
22 Correct 2 ms 704 KB Output is correct
23 Correct 3 ms 704 KB Output is correct
24 Correct 2 ms 704 KB Output is correct
25 Correct 3 ms 704 KB Output is correct
26 Correct 3 ms 704 KB Output is correct
27 Correct 2 ms 704 KB Output is correct
28 Correct 2 ms 704 KB Output is correct
29 Correct 2 ms 704 KB Output is correct
30 Correct 2 ms 752 KB Output is correct
31 Correct 2 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 752 KB Output is correct
2 Correct 2 ms 752 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 14 ms 1660 KB Output is correct
5 Correct 28 ms 3708 KB Output is correct
6 Correct 37 ms 5412 KB Output is correct
7 Correct 52 ms 7396 KB Output is correct
8 Correct 84 ms 11984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 2 ms 400 KB Output is correct
3 Correct 3 ms 412 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 2 ms 704 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 2 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 704 KB Output is correct
15 Correct 2 ms 704 KB Output is correct
16 Correct 2 ms 704 KB Output is correct
17 Correct 2 ms 704 KB Output is correct
18 Correct 2 ms 704 KB Output is correct
19 Correct 2 ms 704 KB Output is correct
20 Correct 2 ms 704 KB Output is correct
21 Correct 2 ms 704 KB Output is correct
22 Correct 2 ms 704 KB Output is correct
23 Correct 3 ms 704 KB Output is correct
24 Correct 2 ms 704 KB Output is correct
25 Correct 3 ms 704 KB Output is correct
26 Correct 3 ms 704 KB Output is correct
27 Correct 2 ms 704 KB Output is correct
28 Correct 2 ms 704 KB Output is correct
29 Correct 2 ms 704 KB Output is correct
30 Correct 2 ms 752 KB Output is correct
31 Correct 2 ms 752 KB Output is correct
32 Correct 2 ms 752 KB Output is correct
33 Correct 2 ms 752 KB Output is correct
34 Correct 2 ms 752 KB Output is correct
35 Correct 14 ms 1660 KB Output is correct
36 Correct 28 ms 3708 KB Output is correct
37 Correct 37 ms 5412 KB Output is correct
38 Correct 52 ms 7396 KB Output is correct
39 Correct 84 ms 11984 KB Output is correct
40 Correct 5 ms 11984 KB Output is correct
41 Correct 5 ms 11984 KB Output is correct
42 Correct 6 ms 11984 KB Output is correct
43 Correct 30 ms 11984 KB Output is correct
44 Correct 85 ms 15380 KB Output is correct
45 Correct 15 ms 15380 KB Output is correct
46 Correct 51 ms 15380 KB Output is correct
47 Correct 73 ms 19284 KB Output is correct
48 Correct 59 ms 21640 KB Output is correct
49 Correct 60 ms 27324 KB Output is correct
50 Correct 61 ms 28976 KB Output is correct