Contest Duration: - (local time) (100 minutes) Back to Home

Submission #3872414

Source Code Expand

Copy
```#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
int N;
cin >> N;
vector<ll> A(N);
for(int i = 0; i < N; i++) {
cin >> A[i];
}
vector<ll> acc(N + 1);
for(int i = 0; i < N; i++) {
acc[i + 1] = acc[i] + A[i];
}

ll ans = 1LL << 62;
for(int j = 2; j <= N - 2; j++) {
int i1 = lower_bound(all(acc), acc[j] / 2) - acc.begin();
int k1 = lower_bound(all(acc), (acc[N] + acc[j]) / 2) - acc.begin();
vector<int> I = {i1}, K = {k1};
if (i1 - 1 >= 0) I.push_back(i1 - 1);
if (k1 - 1 > j) K.push_back(k1 - 1);
for(int u = 0; u < I.size(); u++) {
for(int v = 0; v < K.size(); v++) {
int i = I[u], k = K[v];
vector<ll> sum = {acc[N] - acc[k], acc[k] - acc[j], acc[j] - acc[i], acc[i]};
sort(all(sum));
ans = min(ans, sum.back() - sum[0]);
}
}
}
cout << ans << endl;
return 0;
}```

#### Submission Info

Submission Time 2018-12-25 21:52:55+0900 D - Equal Cut kakira C++14 (GCC 5.4.1) 600 973 Byte AC 151 ms 3328 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
 AC × 3
 AC × 43
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 144 ms 3072 KB
subtask_1_03.txt AC 58 ms 1536 KB
subtask_1_04.txt AC 101 ms 2176 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 17 ms 640 KB
subtask_1_07.txt AC 81 ms 2048 KB
subtask_1_08.txt AC 47 ms 1408 KB
subtask_1_09.txt AC 81 ms 1920 KB
subtask_1_10.txt AC 97 ms 2688 KB
subtask_1_11.txt AC 127 ms 3072 KB
subtask_1_12.txt AC 60 ms 1664 KB
subtask_1_13.txt AC 83 ms 2176 KB
subtask_1_14.txt AC 27 ms 896 KB
subtask_1_15.txt AC 18 ms 640 KB
subtask_1_16.txt AC 60 ms 1920 KB
subtask_1_17.txt AC 51 ms 1664 KB
subtask_1_18.txt AC 4 ms 384 KB
subtask_1_19.txt AC 110 ms 3072 KB
subtask_1_20.txt AC 151 ms 3072 KB
subtask_1_21.txt AC 67 ms 1792 KB
subtask_1_22.txt AC 50 ms 1152 KB
subtask_1_23.txt AC 108 ms 2816 KB
subtask_1_24.txt AC 128 ms 3328 KB
subtask_1_25.txt AC 128 ms 3328 KB
subtask_1_26.txt AC 125 ms 3328 KB
subtask_1_27.txt AC 123 ms 3328 KB
subtask_1_28.txt AC 127 ms 3328 KB
subtask_1_29.txt AC 128 ms 3328 KB
subtask_1_30.txt AC 126 ms 3328 KB
subtask_1_31.txt AC 128 ms 3328 KB
subtask_1_32.txt AC 128 ms 3328 KB
subtask_1_33.txt AC 126 ms 3328 KB
subtask_1_34.txt AC 111 ms 3328 KB
subtask_1_35.txt AC 119 ms 3328 KB
subtask_1_36.txt AC 108 ms 3328 KB
subtask_1_37.txt AC 109 ms 3328 KB