#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab (int x ) { return (x>0?x:-x); }
const int N = 500005 ;
int a[N] , pref[N],n;
int sum(int l , int r ){
if( l > r )return 0;
if( l == 0 )return pref[r];
return pref[r]-pref[l-1] ;
}
int main(){
cin >> n ;
for(int i= 0 ; i< n ; i++ )cin >> a[i] ;
pref[0] = a[0] ;
for(int i = 1 ; i < n ; i++ ){
pref[i] = pref[i-1] + a[i] ;
}
int ans = 1e9;
for(int start = 0 ; start < (n/2)+(n%2) ; start ++ ){
int s = sum(0,start) ;
int res = (n/2+n%2)-start-1;
// cout << start << " " << n-1-res << endl;
s += sum(n-res,n-1);
ans = min(ans,s);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
636 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
380 KB |
Output is correct |
4 |
Correct |
35 ms |
1268 KB |
Output is correct |
5 |
Correct |
75 ms |
2680 KB |
Output is correct |
6 |
Correct |
104 ms |
3320 KB |
Output is correct |
7 |
Correct |
127 ms |
4048 KB |
Output is correct |
8 |
Correct |
203 ms |
6392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |