Submission #652151

# Submission time Handle Problem Language Result Execution time Memory
652151 2022-10-21T14:03:48 Z ymm Hacker (BOI15_hac) C++17
100 / 100
133 ms 10576 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 500'010;
int seg[2*N];

const int inf = 1e9+10;

void up(int l, int r, int x)
{
	l += N;
	r += N;
	while (l < r) {
		if (l&1) {
			seg[l] = min(seg[l], x);
			++l;
		}
		if (r&1) {
			--r;
			seg[r] = min(seg[r], x);
		}
		l /= 2;
		r /= 2;
	}
}

int get(int i)
{
	i += N;
	int ans = inf;
	while (i) {
		ans = min(ans, seg[i]);
		i /= 2;
	}
	return ans;
		
}

int n;
int a[N];
int pre[N];

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	fill(seg, seg+2*N, inf);
	cin >> n;
	Loop (i,0,n) {
		cin >> a[i];
		pre[i+1] = pre[i] + a[i];
	}
	int len = (n+1)/2;
	Loop (i,0,n) {
		if (i+len <= n) {
			int sum = pre[i+len] - pre[i];
			up(i, i+len, sum);
		} else {
			int sum = pre[n] - pre[i] + pre[i+len-n];
			up(i, n, sum);
			up(0, i+len-n, sum);
		}
	}
	int ans = 0;
	Loop (i,0,n)
		ans = max(ans, get(i));
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 3 ms 4180 KB Output is correct
5 Correct 3 ms 4180 KB Output is correct
6 Correct 3 ms 4180 KB Output is correct
7 Correct 3 ms 4180 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 3 ms 4244 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 3 ms 4180 KB Output is correct
12 Correct 3 ms 4244 KB Output is correct
13 Correct 3 ms 4244 KB Output is correct
14 Correct 4 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 3 ms 4180 KB Output is correct
18 Correct 3 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 3 ms 4180 KB Output is correct
5 Correct 3 ms 4180 KB Output is correct
6 Correct 3 ms 4180 KB Output is correct
7 Correct 3 ms 4180 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 3 ms 4244 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 3 ms 4180 KB Output is correct
12 Correct 3 ms 4244 KB Output is correct
13 Correct 3 ms 4244 KB Output is correct
14 Correct 4 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 3 ms 4180 KB Output is correct
18 Correct 3 ms 4180 KB Output is correct
19 Correct 3 ms 4180 KB Output is correct
20 Correct 3 ms 4208 KB Output is correct
21 Correct 4 ms 4240 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 4 ms 4260 KB Output is correct
24 Correct 3 ms 4248 KB Output is correct
25 Correct 5 ms 4308 KB Output is correct
26 Correct 4 ms 4252 KB Output is correct
27 Correct 3 ms 4180 KB Output is correct
28 Correct 2 ms 4180 KB Output is correct
29 Correct 3 ms 4180 KB Output is correct
30 Correct 3 ms 4308 KB Output is correct
31 Correct 5 ms 4308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 4 ms 4308 KB Output is correct
4 Correct 20 ms 5152 KB Output is correct
5 Correct 64 ms 6476 KB Output is correct
6 Correct 61 ms 7276 KB Output is correct
7 Correct 105 ms 7924 KB Output is correct
8 Correct 133 ms 10296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 3 ms 4180 KB Output is correct
5 Correct 3 ms 4180 KB Output is correct
6 Correct 3 ms 4180 KB Output is correct
7 Correct 3 ms 4180 KB Output is correct
8 Correct 4 ms 4180 KB Output is correct
9 Correct 3 ms 4244 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 3 ms 4180 KB Output is correct
12 Correct 3 ms 4244 KB Output is correct
13 Correct 3 ms 4244 KB Output is correct
14 Correct 4 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 3 ms 4180 KB Output is correct
18 Correct 3 ms 4180 KB Output is correct
19 Correct 3 ms 4180 KB Output is correct
20 Correct 3 ms 4208 KB Output is correct
21 Correct 4 ms 4240 KB Output is correct
22 Correct 3 ms 4180 KB Output is correct
23 Correct 4 ms 4260 KB Output is correct
24 Correct 3 ms 4248 KB Output is correct
25 Correct 5 ms 4308 KB Output is correct
26 Correct 4 ms 4252 KB Output is correct
27 Correct 3 ms 4180 KB Output is correct
28 Correct 2 ms 4180 KB Output is correct
29 Correct 3 ms 4180 KB Output is correct
30 Correct 3 ms 4308 KB Output is correct
31 Correct 5 ms 4308 KB Output is correct
32 Correct 3 ms 4180 KB Output is correct
33 Correct 2 ms 4180 KB Output is correct
34 Correct 4 ms 4308 KB Output is correct
35 Correct 20 ms 5152 KB Output is correct
36 Correct 64 ms 6476 KB Output is correct
37 Correct 61 ms 7276 KB Output is correct
38 Correct 105 ms 7924 KB Output is correct
39 Correct 133 ms 10296 KB Output is correct
40 Correct 5 ms 4308 KB Output is correct
41 Correct 6 ms 4436 KB Output is correct
42 Correct 9 ms 4572 KB Output is correct
43 Correct 46 ms 6588 KB Output is correct
44 Correct 118 ms 10296 KB Output is correct
45 Correct 28 ms 5332 KB Output is correct
46 Correct 71 ms 7892 KB Output is correct
47 Correct 114 ms 10300 KB Output is correct
48 Correct 113 ms 10576 KB Output is correct
49 Correct 114 ms 9700 KB Output is correct
50 Correct 132 ms 9704 KB Output is correct