답안 #967618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967618 2024-04-22T14:09:33 Z NintsiChkhaidze Hacker (BOI15_hac) C++17
100 / 100
205 ms 35916 KB
#include <bits/stdc++.h>
#define ll long long
#define s second
#define f first
#define pb push_back
#define left (h*2),l,(l + r)/2
#define right (h*2+1),(l+r)/2 + 1,r
#define pii pair <int,int>
#define int ll
using namespace std;
 
const int N = 1e6 + 5,inf = 1e18;
int lz[4*N],t[4*N],p[N],a[N];
 
void build(int h,int l,int r){
	t[h] = inf;
	if (l == r) return;
	build(left);
	build(right);
}
 
void upd(int h,int l,int r,int L,int R,int vl){
	if (r < L || R < l) return ;
	if (L <= l && r <= R) {
		t[h] = min(t[h],vl);
		return;
	}
	upd(left,L,R,vl);
	upd(right,L,R,vl);
}
 
int get(int h,int l,int r,int idx){
	if (l == r) return t[h];
	if (idx > (l + r)/2) return min(t[h],get(right,idx));
	return min(t[h],get(left,idx));
}
signed main(){
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	
	int n;
	cin>>n;
 
	for (int i =1; i <= n; i++){
		cin >> a[i];
		p[i] = p[i - 1] + a[i];
	}
 
	for (int i = n + 1; i <= 2*n; i++)
		a[i] = a[i - n],p[i] = p[i - 1] + a[i];
 
	build(1,1,2*n);
	int len = (n + 1)/2;
	for (int i = 1; i <= n; i++)
		upd(1,1,2*n,i, i + len - 1,p[i + len - 1] - p[i - 1]);
	
	int ans = 0;
	for (int i = n + 1; i <= 2*n; i++)
		ans = max(ans,min(get(1,1,2*n,i),get(1,1,2*n,i - n)));
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2516 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 2484 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2516 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 2484 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2648 KB Output is correct
24 Correct 2 ms 2392 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 3 ms 2652 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 35 ms 11848 KB Output is correct
5 Correct 80 ms 20312 KB Output is correct
6 Correct 100 ms 20572 KB Output is correct
7 Correct 135 ms 33556 KB Output is correct
8 Correct 205 ms 35636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2516 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 2 ms 2484 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2648 KB Output is correct
24 Correct 2 ms 2392 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 3 ms 2652 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 35 ms 11848 KB Output is correct
36 Correct 80 ms 20312 KB Output is correct
37 Correct 100 ms 20572 KB Output is correct
38 Correct 135 ms 33556 KB Output is correct
39 Correct 205 ms 35636 KB Output is correct
40 Correct 4 ms 2652 KB Output is correct
41 Correct 8 ms 6988 KB Output is correct
42 Correct 12 ms 7260 KB Output is correct
43 Correct 87 ms 20532 KB Output is correct
44 Correct 204 ms 35644 KB Output is correct
45 Correct 39 ms 11864 KB Output is correct
46 Correct 132 ms 33284 KB Output is correct
47 Correct 200 ms 35636 KB Output is correct
48 Correct 203 ms 35916 KB Output is correct
49 Correct 199 ms 34984 KB Output is correct
50 Correct 202 ms 34896 KB Output is correct