Submission #120025

# Submission time Handle Problem Language Result Execution time Memory
120025 2019-06-23T04:51:33 Z E869120 Hacker (BOI15_hac) C++14
100 / 100
233 ms 22412 KB
#include <iostream>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

long long N, A[1 << 20], C[1 << 20],  T[1 << 20];

bool solve(long long pos) {
	for (int i = 0; i <= N * 2; i++) T[i] = 0;
	for (int i = 0; i < N; i++) {
		long long E = C[i + (N + 1) / 2] - C[i];
		if (E >= pos) { T[i + 1] = 1; T[i + 1 + N] = 1;}
	}
	for (int i = 1; i <= 2 * N; i++) T[i] += T[i - 1];

	for (int i = 0; i < N; i++) {
		if (T[i + (N + 1) / 2] - T[i] == (N + 1) / 2) return true;
	}
	return false;
}

int main() {
	scanf("%lld", &N);
	for (int i = 1; i <= N; i++) { scanf("%lld", &A[i]); C[i] = A[i]; C[i + N] = C[i]; }
	for (int i = 1; i <= N * 2; i++) C[i] += C[i - 1];

	long long cl = 0, cr = (1LL << 30), cm, maxn = -(1LL << 30);
	for (int i = 0; i < 33; i++) {
		cm = (cl + cr) / 2;
		bool I = solve(cm);
		if (I == true) { cl = cm; maxn = max(maxn, cm); }
		else { cr = cm; }
	}
	cout << maxn << endl;
	return 0;
}

Compilation message

hac.cpp:4:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
hac.cpp: In function 'int main()':
hac.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N);
  ~~~~~^~~~~~~~~~~~
hac.cpp:24:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= N; i++) { scanf("%lld", &A[i]); C[i] = A[i]; C[i + N] = C[i]; }
                                 ~~~~~^~~~~~~~~~~~~~~
# 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 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 372 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 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 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 372 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 412 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 4 ms 640 KB Output is correct
23 Correct 4 ms 640 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 5 ms 588 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 4 ms 512 KB Output is correct
31 Correct 4 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 4 ms 640 KB Output is correct
4 Correct 33 ms 3960 KB Output is correct
5 Correct 75 ms 8992 KB Output is correct
6 Correct 98 ms 11256 KB Output is correct
7 Correct 125 ms 13432 KB Output is correct
8 Correct 229 ms 22136 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 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 372 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 412 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 4 ms 640 KB Output is correct
23 Correct 4 ms 640 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 4 ms 640 KB Output is correct
26 Correct 5 ms 588 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 4 ms 512 KB Output is correct
31 Correct 4 ms 640 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 4 ms 640 KB Output is correct
35 Correct 33 ms 3960 KB Output is correct
36 Correct 75 ms 8992 KB Output is correct
37 Correct 98 ms 11256 KB Output is correct
38 Correct 125 ms 13432 KB Output is correct
39 Correct 229 ms 22136 KB Output is correct
40 Correct 6 ms 896 KB Output is correct
41 Correct 10 ms 1284 KB Output is correct
42 Correct 14 ms 1664 KB Output is correct
43 Correct 81 ms 9100 KB Output is correct
44 Correct 233 ms 22136 KB Output is correct
45 Correct 39 ms 4728 KB Output is correct
46 Correct 126 ms 13560 KB Output is correct
47 Correct 223 ms 22136 KB Output is correct
48 Correct 195 ms 22412 KB Output is correct
49 Correct 194 ms 21496 KB Output is correct
50 Correct 194 ms 21572 KB Output is correct