#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];
void md(int &x)
{
x+=n;
x%=n;
if(!x)x=n;
}
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++)
{
md(t);
cur+=a[t];
}
curmx=cur;
for(p=i-nr;p<i;p++,t++)
{
md(t),md(p);
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--)
{
md(t);
cur+=a[t];
}
curmx=max(curmx,cur);
for(p=i+nr;t>j;t--,p--)
{
md(t),md(p);
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++)
{
md(t);
cur+=a[t];
}
curmx=cur;
for(p=i+nr;p>i;p--,t--)
{
md(t),md(p);
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++)
{
md(t);
cur+=a[t];
}
curmx=max(curmx,cur);
for(p=i-nr;t<j;t++,p++)
{
md(t),md(p);
cur+=a[t];
cur-=a[p];
curmx=max(curmx,cur);
}
}
curmn=min(curmn,curmx);
}
rs=max(rs,curmn);
}
cout<<rs<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |