Submission #31736

# Submission time Handle Problem Language Result Execution time Memory
31736 2017-09-03T06:30:57 Z kdh9949 Hacker (BOI15_hac) C++14
100 / 100
186 ms 14112 KB
#include <bits/stdc++.h>
using namespace std;

const int MN = 500005, sz = 1048576, inf = int(2e9) + 5;
struct Seg{
	int dat[2 * sz];
	void ini(){ fill(dat + 1, dat + 2 * sz, inf); }
	void upd(int x, int v){
		x += sz; dat[x] = v;
		for(x /= 2; x; x /= 2) dat[x] = min(dat[2 * x], dat[2 * x + 1]);
	}
	int get(int s, int e){
		int ret = inf;
		for(s += sz, e += sz; s <= e; s /= 2, e /= 2){
			if(s % 2 == 1) ret = min(ret, dat[s++]);
			if(e % 2 == 0) ret = min(ret, dat[e--]);
		}
		return ret;
	}
} S;

int n, m, s[2 * MN], ans;

int main(){
	scanf("%d", &n);
	m = (n + 1) / 2;
	for(int i = 1; i <= n; i++){
		scanf("%d", s + i);
		s[n + i] = s[i];
	}
	S.ini();
	for(int i = 2; i <= 2 * n; i++) s[i] += s[i - 1];
	for(int i = 0; i + m <= 2 * n; i++) S.upd(i, s[i + m] - s[i]);
	for(int i = m - 1; i + m <= 2 * n; i++) ans = max(ans, S.get(i - m + 1, i));
	printf("%d\n", ans);
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:25:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
hac.cpp:28:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", s + i);
                     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 14112 KB Output is correct
2 Correct 3 ms 14112 KB Output is correct
3 Correct 3 ms 14112 KB Output is correct
4 Correct 0 ms 14112 KB Output is correct
5 Correct 3 ms 14112 KB Output is correct
6 Correct 3 ms 14112 KB Output is correct
7 Correct 3 ms 14112 KB Output is correct
8 Correct 0 ms 14112 KB Output is correct
9 Correct 3 ms 14112 KB Output is correct
10 Correct 3 ms 14112 KB Output is correct
11 Correct 0 ms 14112 KB Output is correct
12 Correct 3 ms 14112 KB Output is correct
13 Correct 0 ms 14112 KB Output is correct
14 Correct 0 ms 14112 KB Output is correct
15 Correct 3 ms 14112 KB Output is correct
16 Correct 0 ms 14112 KB Output is correct
17 Correct 3 ms 14112 KB Output is correct
18 Correct 3 ms 14112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 14112 KB Output is correct
2 Correct 3 ms 14112 KB Output is correct
3 Correct 3 ms 14112 KB Output is correct
4 Correct 0 ms 14112 KB Output is correct
5 Correct 3 ms 14112 KB Output is correct
6 Correct 3 ms 14112 KB Output is correct
7 Correct 3 ms 14112 KB Output is correct
8 Correct 0 ms 14112 KB Output is correct
9 Correct 3 ms 14112 KB Output is correct
10 Correct 3 ms 14112 KB Output is correct
11 Correct 0 ms 14112 KB Output is correct
12 Correct 3 ms 14112 KB Output is correct
13 Correct 0 ms 14112 KB Output is correct
14 Correct 0 ms 14112 KB Output is correct
15 Correct 3 ms 14112 KB Output is correct
16 Correct 0 ms 14112 KB Output is correct
17 Correct 3 ms 14112 KB Output is correct
18 Correct 3 ms 14112 KB Output is correct
19 Correct 0 ms 14112 KB Output is correct
20 Correct 0 ms 14112 KB Output is correct
21 Correct 0 ms 14112 KB Output is correct
22 Correct 6 ms 14112 KB Output is correct
23 Correct 3 ms 14112 KB Output is correct
24 Correct 6 ms 14112 KB Output is correct
25 Correct 6 ms 14112 KB Output is correct
26 Correct 3 ms 14112 KB Output is correct
27 Correct 0 ms 14112 KB Output is correct
28 Correct 0 ms 14112 KB Output is correct
29 Correct 0 ms 14112 KB Output is correct
30 Correct 3 ms 14112 KB Output is correct
31 Correct 3 ms 14112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 14112 KB Output is correct
2 Correct 3 ms 14112 KB Output is correct
3 Correct 3 ms 14112 KB Output is correct
4 Correct 33 ms 14112 KB Output is correct
5 Correct 66 ms 14112 KB Output is correct
6 Correct 103 ms 14112 KB Output is correct
7 Correct 99 ms 14112 KB Output is correct
8 Correct 183 ms 14112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 14112 KB Output is correct
2 Correct 3 ms 14112 KB Output is correct
3 Correct 3 ms 14112 KB Output is correct
4 Correct 0 ms 14112 KB Output is correct
5 Correct 3 ms 14112 KB Output is correct
6 Correct 3 ms 14112 KB Output is correct
7 Correct 3 ms 14112 KB Output is correct
8 Correct 0 ms 14112 KB Output is correct
9 Correct 3 ms 14112 KB Output is correct
10 Correct 3 ms 14112 KB Output is correct
11 Correct 0 ms 14112 KB Output is correct
12 Correct 3 ms 14112 KB Output is correct
13 Correct 0 ms 14112 KB Output is correct
14 Correct 0 ms 14112 KB Output is correct
15 Correct 3 ms 14112 KB Output is correct
16 Correct 0 ms 14112 KB Output is correct
17 Correct 3 ms 14112 KB Output is correct
18 Correct 3 ms 14112 KB Output is correct
19 Correct 0 ms 14112 KB Output is correct
20 Correct 0 ms 14112 KB Output is correct
21 Correct 0 ms 14112 KB Output is correct
22 Correct 6 ms 14112 KB Output is correct
23 Correct 3 ms 14112 KB Output is correct
24 Correct 6 ms 14112 KB Output is correct
25 Correct 6 ms 14112 KB Output is correct
26 Correct 3 ms 14112 KB Output is correct
27 Correct 0 ms 14112 KB Output is correct
28 Correct 0 ms 14112 KB Output is correct
29 Correct 0 ms 14112 KB Output is correct
30 Correct 3 ms 14112 KB Output is correct
31 Correct 3 ms 14112 KB Output is correct
32 Correct 0 ms 14112 KB Output is correct
33 Correct 3 ms 14112 KB Output is correct
34 Correct 3 ms 14112 KB Output is correct
35 Correct 33 ms 14112 KB Output is correct
36 Correct 66 ms 14112 KB Output is correct
37 Correct 103 ms 14112 KB Output is correct
38 Correct 99 ms 14112 KB Output is correct
39 Correct 183 ms 14112 KB Output is correct
40 Correct 3 ms 14112 KB Output is correct
41 Correct 6 ms 14112 KB Output is correct
42 Correct 13 ms 14112 KB Output is correct
43 Correct 79 ms 14112 KB Output is correct
44 Correct 183 ms 14112 KB Output is correct
45 Correct 33 ms 14112 KB Output is correct
46 Correct 109 ms 14112 KB Output is correct
47 Correct 186 ms 14112 KB Output is correct
48 Correct 179 ms 14112 KB Output is correct
49 Correct 166 ms 14112 KB Output is correct
50 Correct 163 ms 14112 KB Output is correct