This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << endl
#define all(x) x.begin(),x.end()
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n;cin>>n;
int m=(n+1)/2;
int a[n],cnt[n],sum=0;
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<m;i++) sum+=a[i];
for(int i=0;i<n;i++)
{
cnt[i]=sum;
sum-=a[i];
sum+=(a[(i+m)%n]);
}
multiset<int> s;
for(int i=0;i<m;i++) s.insert(cnt[i]);
int ans=0;
for(int i=0;i<n;i++)
{
ans=max(ans,*s.begin());
s.erase(s.find(cnt[i]));
s.insert(cnt[(i+m)%n]);
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |