Submission #1128027

#TimeUsernameProblemLanguageResultExecution timeMemory
1128027AgageldiHacker (BOI15_hac)C++20
100 / 100
280 ms22100 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 4000005 #define ff first #define ss second #define pb push_back #define sz(s) (int)s.size() #define rep(c, a, b) for(c = a; c <= b; c++) ll n, v[N], mx, sum, answer, k, l; multiset <ll> s; deque <ll> d; int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> n; k = (n+1)/2; for(int i = 1; i <= n; i++) { cin >> v[i]; if(i <= k) sum += v[i]; } for(int i = 1; i <= n; i++) { v[i + n] = v[i]; } l = 1; s.insert(sum); d.pb(sum); for(int i = k + 1; i <= 2*n; i++) { sum -= v[l]; sum += v[i]; d.pb(sum); s.insert(sum); if(sz(s) == k) { mx = max(mx,(*s.begin())); s.erase(s.find(d[0])); d.pop_front(); } l++; } cout << mx << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...