#include <bits/stdc++.h>
using namespace std;
const int N=301;
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n;
cin>>n;
vector<int> a,b;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
a.push_back(x);
}
for(auto y:a)
b.push_back(y);
for(auto y:a)
b.push_back(y);
vector<int> pre={0};
for(int i:b)
pre.push_back(pre.back()+i);
int sz=n-(n/2);
int mx=0;
for(int i=1;i<=(2*n);i++)
{
vector<int> val;
if((i+sz-1)<=(2*n))
{
val.push_back(pre[i+sz-1]-pre[i-1]);
}
if((i-sz+1)>=(1))
{
val.push_back(pre[i]-pre[i-sz]);
}
sort(begin(val),end(val));
mx=max(mx,val[0]);
}
cout<<mx<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |