#include <bits/stdc++.h>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n;
ll arr[1000001];
ll precal[1000001];
set<pair<ll,ll>>s;
ll sum=0;
void solve(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>arr[i];
sum+=arr[i];
}
for(int i=1;i<=n/2;i++){
precal[1]+=arr[i];
}
s.insert({precal[1],1});
for(int i=2,j=n/2+1;max(i,j)<=n;i++,j++){
precal[i]=precal[i-1]+arr[j]-arr[i-1];
s.insert({precal[i],i});
}
for(int j=1,i=n/2+2;max(i,j)<=n;i++,j++){
precal[i]=precal[i-1]+arr[j]-arr[i-1];
s.insert({precal[i],i});
}
ll mx=-1;
for(int i=1;i<=n;i++){
auto it=s.rbegin();
if((*it).second==i) it++;
mx=max(mx,sum-(*it).first);
}
co mx;
}
int main()
{
suiii
int tt=1;
// cin>>tt;
while(tt--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |