Submission #101128

# Submission time Handle Problem Language Result Execution time Memory
101128 2019-03-16T18:37:12 Z luciocf Hacker (BOI15_hac) C++14
40 / 100
135 ms 640 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 5e3+10;

int v[maxn], soma[maxn];

int main(void)
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> v[i];

		if (i > 0) soma[i] = soma[i-1] + v[i];
		else soma[i] = v[i];
	}

	int ans = 0, sz = (n+1)/2;

	for (int i = 0; i < n; i++)
	{
		int aux = 1e9+10;

		for (int qtd = 1, r = i; qtd <= sz; qtd++, r = (r+1)%n)
		{
			int resto = sz-qtd;
			int l = (i-resto+n)%n;

			int s1, s2;

			if (r >= 0 && r < i) s2 = (soma[n-1]-soma[i])+soma[r];
			else s2 = soma[r]-soma[i];

			if (l < n && l > i) s1 = soma[i]+(soma[n-1]-soma[l-1]);
			else s1 = (l ? soma[i]-soma[l-1] : soma[i]);

			aux = min(aux, s1+s2);
		}

		ans = max(ans, aux);
	}

	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 368 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 10 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 368 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 10 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 9 ms 384 KB Output is correct
21 Correct 6 ms 256 KB Output is correct
22 Correct 49 ms 412 KB Output is correct
23 Correct 124 ms 384 KB Output is correct
24 Correct 48 ms 384 KB Output is correct
25 Correct 135 ms 424 KB Output is correct
26 Correct 126 ms 384 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 122 ms 384 KB Output is correct
31 Correct 126 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 119 ms 384 KB Output is correct
4 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 368 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 10 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 9 ms 384 KB Output is correct
21 Correct 6 ms 256 KB Output is correct
22 Correct 49 ms 412 KB Output is correct
23 Correct 124 ms 384 KB Output is correct
24 Correct 48 ms 384 KB Output is correct
25 Correct 135 ms 424 KB Output is correct
26 Correct 126 ms 384 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 122 ms 384 KB Output is correct
31 Correct 126 ms 408 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 119 ms 384 KB Output is correct
35 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Halted 0 ms 0 KB -