Submission #310194

#TimeUsernameProblemLanguageResultExecution timeMemory
310194nicolaalexandraHacker (BOI15_hac)C++14
100 / 100
262 ms11812 KiB
#include <bits/stdc++.h> #define DIM 1000010 using namespace std; int v[DIM],sp[DIM]; deque <pair<int,int> > d; int n,i; int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n; for (i=1;i<=n;i++) cin>>v[i]; int lg = (n+1) / 2; for (i=n+1;i<=2*n;i++) v[i] = v[i-n]; for (i=1;i<=2*n;i++) sp[i] = sp[i-1] + v[i]; for (i=lg;i<2*lg;i++){ while (!d.empty() && sp[i] - sp[i-lg] <= d.back().first) d.pop_back(); d.push_back(make_pair(sp[i] - sp[i-lg],i)); } int sol = d.front().first; for (i=2*lg;i<=2*n;i++){ while (!d.empty() && sp[i] - sp[i-lg] <= d.back().first) d.pop_back(); d.push_back(make_pair(sp[i] - sp[i-lg],i)); while (d.front().second <= i-lg) d.pop_front(); sol = max (sol,d.front().first); } cout<<sol; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...