/*input
5
1 2 3 4 5
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 500005
int n;
int a[N];
int sum[N];
int get(int l, int r) {
return sum[r] - sum[l - 1];
}
int ceil(int x, int y) {
int ret = x / y;
if (x % y) ret++;
return ret;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
int ans = 1e18;
for (int j = 2; j <= n; j++) {
int left = (ceil(n, 2) - (j - 1));
if (left < 0) break;
ans = min(ans, get(1, j - 1) + get(n - left + 1, n));
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
9988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
9988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
6 ms |
9988 KB |
Output is correct |
5 |
Correct |
19 ms |
9988 KB |
Output is correct |
6 |
Correct |
26 ms |
9988 KB |
Output is correct |
7 |
Correct |
33 ms |
9988 KB |
Output is correct |
8 |
Correct |
49 ms |
9988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
9988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |