# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
179983 |
2020-01-08T11:35:35 Z |
MvC |
Hacker (BOI15_hac) |
C++11 |
|
2 ms |
416 KB |
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=5e5+50;
const int mod=1e9+7;
using namespace std;
int n,i,j,t,p,nr,cur,curmx,curmn,rs,a[nmax];
int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)cin>>a[i];
for(i=1;i<=n;i++)
{
curmn=inf;
for(j=1;j<=n;j++)
{
if(i==j)continue;
if(i>j)
{
nr=(i-j)/2,cur=0;
for(t=i-nr,p=1;p<=(n+1)/2;t++,p++)
{
if(t==n+1)t=1;
cur+=a[t];
}
curmx=cur;
for(p=i-nr;p<i;p++,t++)
{
if(t==n+1)t=1;
cur-=a[p];
cur+=a[t];
curmx=max(curmx,cur);
}
nr=(n-(i-j+1)+1)/2,cur=0;
for(t=i+nr,p=1;p<=(n+1)/2;p++,t--)
{
t%=n;
if(!t)t=n;
cur+=a[t];
}
curmx=max(curmx,cur);
for(p=i+nr;t>j;t--,p--)
{
t%=n,p%=n;
if(!t)t=n;
if(!p)p=n;
cur+=a[t];
cur-=a[p];
curmx=max(curmx,cur);
}
}
else
{
nr=(j-i)/2,cur=0;
for(t=i+nr,p=1;p<=(n+1)/2;t--,p++)
{
t%=n;
if(!t)t=n;
cur+=a[t];
}
curmx=cur;
for(p=i+nr;p>i;p--,t--)
{
t%=n,p%=n;
if(!t)t=n;
if(!p)p=n;
cur-=a[p];
cur+=a[t];
curmx=max(curmx,cur);
}
nr=(n-(j-i+1)+1)/2,cur=0;
for(t=i-nr,p=1;p<=(n+1)/2;p++,t++)
{
t=(t+n)%n;
if(!t)t=n;
cur+=a[t];
}
curmx=max(curmx,cur);
for(p=i-nr;t<j;t++,p++)
{
t=(t+n)%n,p=(p+n)%n;
if(!t)t=n;
if(!p)p=n;
cur+=a[t];
cur-=a[p];
curmx=max(curmx,cur);
}
}
curmn=min(curmn,curmx);
}
rs=max(rs,curmn);
}
cout<<rs<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
416 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
416 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
416 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |