# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
203344 |
2020-02-20T09:20:58 Z |
Fasho |
Hacker (BOI15_hac) |
C++14 |
|
5 ms |
384 KB |
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;
ll n,m,ar[N],sum,t,pref[N];
ll calc1(int ind,int len)
{
ll top=0;
if(ind-len<1)
{
top+=pref[ind-1];
ll x=1-(ind-len);
top+=pref[n]-pref[n-x];
return top;
}
return pref[ind-1]-pref[ind-len-1];
}
ll calc2(int ind,int len)
{
if(ind+len<=n)
return pref[ind+len]-pref[ind];
ll top=0;
top+=pref[n]-pref[ind];
ll x=ind+len-n;
return top+pref[x];
}
int main()
{
fast;
cin>>n;
fs(ar,n);
pref[0]=0;
fo(i,1,n)
pref[i]=pref[i-1]+ar[i];
m=(n+1)/2;
m--;
// cout<<calc1(1,1)<<endl;
fo(i,1,n)
{
ll top=ar[i];
ll x=calc1(i,m);
ll y=calc2(i,m);
// cout<<i<<sp<<x<<sp<<y<<endl;
top+=min(x,y);
sum=max(sum,top);
}
cout<<sum;
}
/* cd onedrive\desktop\kod
cls
Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |