답안 #926269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926269 2024-02-12T18:09:06 Z Nonoze Hacker (BOI15_hac) C++17
0 / 100
0 ms 428 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];
	int mx=0;
	for (int i=1; i<n; i++) {
		sum[i]=sum[i-1]+a[(i+mid-1)%n]-a[i-1];
		mx=max(mx, sum[i]);
	}
	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) {
			curr.pop();
			retire[curr.top()]--;
		}
	}
	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 0 ms 348 KB Output is correct
2 Incorrect 0 ms 428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 428 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 428 KB Output isn't correct
3 Halted 0 ms 0 KB -