답안 #926373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926373 2024-02-12T20:50:48 Z Nonoze Hacker (BOI15_hac) C++17
100 / 100
41 ms 5400 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(3)

void solve() {
	int n; cin >> n;
	int mid=n/2+n%2, x;
	vector<int> a(n+n);
	int sm=0;
	for (int i=0; i<mid; i++) {
		cin >> x;
		sm+=x;
		a[i]=(x+(i?a[i-1]:0));
		a[i+n]=a[i];
	}
	for (int i=mid; i<n; i++) {
		cin >> x;
		a[i]=(x+a[i-1]);
		a[i+n]=a[i];
	}
	for (int i=n; i<n+n; i++) a[i]+=a[n-1];
	deque<int> curr;
	for (int i=0; i<mid; i++) {
		while (!curr.empty() && a[curr.front()+mid-1]-(curr.front()?a[curr.front()-1]:0)>=a[i+mid-1]-a[i-1]) curr.pop_front();
		curr.push_front(i);
	}
	int ans=0;
	for (int i=mid; i<n+mid; i++) {
		ans=max(ans, a[curr.back()+mid-1]-a[curr.back()-1]);
		while (!curr.empty() && a[curr.front()+mid-1]-a[curr.front()-1]>=a[i+mid-1]-a[i-1]) curr.pop_front();
		if (!curr.empty() && curr.back()==i-mid) curr.pop_back();
		curr.push_front(i);
	}
	cout << ans << endl;
	return;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 7 ms 856 KB Output is correct
5 Correct 15 ms 1884 KB Output is correct
6 Correct 20 ms 2428 KB Output is correct
7 Correct 24 ms 2648 KB Output is correct
8 Correct 38 ms 4612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 7 ms 856 KB Output is correct
36 Correct 15 ms 1884 KB Output is correct
37 Correct 20 ms 2428 KB Output is correct
38 Correct 24 ms 2648 KB Output is correct
39 Correct 38 ms 4612 KB Output is correct
40 Correct 1 ms 600 KB Output is correct
41 Correct 2 ms 792 KB Output is correct
42 Correct 3 ms 676 KB Output is correct
43 Correct 16 ms 1884 KB Output is correct
44 Correct 38 ms 4188 KB Output is correct
45 Correct 8 ms 1116 KB Output is correct
46 Correct 23 ms 2652 KB Output is correct
47 Correct 39 ms 4188 KB Output is correct
48 Correct 41 ms 4360 KB Output is correct
49 Correct 28 ms 5200 KB Output is correct
50 Correct 27 ms 5400 KB Output is correct