Submission #727494

# Submission time Handle Problem Language Result Execution time Memory
727494 2023-04-20T21:12:29 Z AdamGS Hacker (BOI15_hac) C++17
100 / 100
104 ms 8720 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7, INF=1e9+7;
int tr[4*LIM], T[LIM], n, N=1;
int cnt(int l, int r) {
	if(l>r) return INF;
	l+=N; r+=N;
	int ans=min(tr[l], tr[r]);
	while(l/2!=r/2) {
		if(l%2==0) ans=min(ans, tr[l+1]);
		if(r%2==1) ans=min(ans, tr[r-1]);
		l/=2; r/=2;
	}
	return ans;
}
int ile(int x) {
	int y=(x+(n+1)/2-1)%n;
	if(y<x) return min(cnt(x, n-1), cnt(0, y));
	return cnt(x, y);
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	while(N<n) N*=2;
	rep(i, n) cin >> T[i];
	rep(i, (n+1)/2) tr[N]+=T[i];
	rep(i, n-1) tr[N+i+1]=tr[N+i]+T[((n+1)/2+i)%n]-T[i];
	for(int i=N-1; i>=0; --i) tr[i]=min(tr[2*i], tr[2*i+1]);
	int ans=0;
	rep(i, n) ans=max(ans, ile(i));
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 368 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 16 ms 1748 KB Output is correct
5 Correct 37 ms 3668 KB Output is correct
6 Correct 53 ms 4388 KB Output is correct
7 Correct 59 ms 6032 KB Output is correct
8 Correct 97 ms 8412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 368 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 16 ms 1748 KB Output is correct
36 Correct 37 ms 3668 KB Output is correct
37 Correct 53 ms 4388 KB Output is correct
38 Correct 59 ms 6032 KB Output is correct
39 Correct 97 ms 8412 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 5 ms 596 KB Output is correct
42 Correct 6 ms 728 KB Output is correct
43 Correct 39 ms 3796 KB Output is correct
44 Correct 104 ms 8448 KB Output is correct
45 Correct 19 ms 1856 KB Output is correct
46 Correct 62 ms 6024 KB Output is correct
47 Correct 101 ms 8396 KB Output is correct
48 Correct 97 ms 8720 KB Output is correct
49 Correct 94 ms 7828 KB Output is correct
50 Correct 92 ms 7856 KB Output is correct