답안 #926317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926317 2024-02-12T19:20:18 Z Nonoze Hacker (BOI15_hac) C++17
100 / 100
228 ms 45068 KB
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long long ll;


#define int long long
#define sz(x) (int)(x.size())
#define debug(x) cerr << (#x) << ": " << (x) << endl
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


int n, k, m;
vector<int> a;

void solve() {
	cin >> n;
	a.clear(), a.resize(n);
	for (auto &u: a) cin >> u;
	vector<int> sum(n, 0);
	int mid=n/2+n%2;
	for (int i=0; i<mid; i++) sum[0]+=a[i];
	for (int i=1; i<n; i++) {
		sum[i]=sum[i-1]+a[(i+mid-1)%n]-a[i-1];
	}
	sum.insert(sum.end(), all(sum));
	priority_queue<int, vector<int>, greater<int>> curr;
	for (int i=0; i<mid; i++) curr.push(sum[i]);
	unordered_map<int, int> retire;
	int ans=0;
	for (int i=mid; i<sz(sum); i++) {
		ans=max(ans, curr.top());
		curr.push(sum[i]);
		retire[sum[i-mid]]++;
		while (retire[curr.top()]>0) {
			retire[curr.top()]--;
			curr.pop();
		}
	}
	cout << ans << endl;
	return;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tt=1;// cin >> tt;
	while(tt--) 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 600 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 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 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 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 0 ms 348 KB Output is correct
4 Correct 0 ms 600 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 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 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 348 KB Output is correct
19 Correct 0 ms 344 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 604 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 860 KB Output is correct
26 Correct 2 ms 600 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 344 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 24 ms 6372 KB Output is correct
5 Correct 56 ms 16232 KB Output is correct
6 Correct 78 ms 22188 KB Output is correct
7 Correct 73 ms 23292 KB Output is correct
8 Correct 114 ms 33960 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 600 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 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 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 348 KB Output is correct
19 Correct 0 ms 344 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 604 KB Output is correct
23 Correct 1 ms 860 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 860 KB Output is correct
26 Correct 2 ms 600 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 344 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 24 ms 6372 KB Output is correct
36 Correct 56 ms 16232 KB Output is correct
37 Correct 78 ms 22188 KB Output is correct
38 Correct 73 ms 23292 KB Output is correct
39 Correct 114 ms 33960 KB Output is correct
40 Correct 3 ms 1116 KB Output is correct
41 Correct 4 ms 1980 KB Output is correct
42 Correct 8 ms 2668 KB Output is correct
43 Correct 49 ms 17216 KB Output is correct
44 Correct 136 ms 33860 KB Output is correct
45 Correct 19 ms 6476 KB Output is correct
46 Correct 80 ms 22852 KB Output is correct
47 Correct 122 ms 35084 KB Output is correct
48 Correct 71 ms 18448 KB Output is correct
49 Correct 228 ms 45068 KB Output is correct
50 Correct 222 ms 44304 KB Output is correct