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

Submission #2787229

Source Code Expand

Copy
```#include <iostream>
#include <vector>
#include <algorithm>

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; j++) {
int i1 = lower_bound(acc.begin(), acc.begin() + j, acc[j] / 2) - acc.begin();
int i2 = i1 - 1;
int k1 = lower_bound(acc.begin() + j, acc.end(), (acc[N] - acc[j]) / 2 + acc[j]) - acc.begin();
int k2 = k1 - 1;
vector<int> I = {i1}, K = {k1};
if (i2 > 0) I.push_back(i2);
if (k2 > j) K.push_back(k2);
for(int ii = 0; ii < I.size(); ii++) {
for(int kk = 0; kk < K.size(); kk++) {
int i = I[ii], k = K[kk];
vector<ll> area;
area.push_back(acc[i]);
area.push_back(acc[j] - acc[i]);
area.push_back(acc[k] - acc[j]);
area.push_back(acc[N] - acc[k]);
sort(area.begin(), area.end());
ans = min(ans, area.back() - area[0]);
}
}
}
cout << ans << endl;
return 0;
}```

#### Submission Info

Submission Time 2018-07-03 22:01:19+0900 D - Equal Cut kakira C++14 (GCC 5.4.1) 600 1169 Byte AC 218 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 213 ms 3072 KB
subtask_1_03.txt AC 93 ms 1536 KB
subtask_1_04.txt AC 147 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 123 ms 2048 KB
subtask_1_08.txt AC 50 ms 1408 KB
subtask_1_09.txt AC 119 ms 1920 KB
subtask_1_10.txt AC 156 ms 2688 KB
subtask_1_11.txt AC 188 ms 3072 KB
subtask_1_12.txt AC 62 ms 1664 KB
subtask_1_13.txt AC 128 ms 2176 KB
subtask_1_14.txt AC 41 ms 896 KB
subtask_1_15.txt AC 26 ms 640 KB
subtask_1_16.txt AC 63 ms 1920 KB
subtask_1_17.txt AC 85 ms 1664 KB
subtask_1_18.txt AC 4 ms 384 KB
subtask_1_19.txt AC 176 ms 3072 KB
subtask_1_20.txt AC 218 ms 3072 KB
subtask_1_21.txt AC 104 ms 1792 KB
subtask_1_22.txt AC 73 ms 1152 KB
subtask_1_23.txt AC 177 ms 2816 KB
subtask_1_24.txt AC 137 ms 3328 KB
subtask_1_25.txt AC 142 ms 3328 KB
subtask_1_26.txt AC 161 ms 3328 KB
subtask_1_27.txt AC 201 ms 3328 KB
subtask_1_28.txt AC 202 ms 3328 KB
subtask_1_29.txt AC 207 ms 3328 KB
subtask_1_30.txt AC 207 ms 3328 KB
subtask_1_31.txt AC 205 ms 3328 KB
subtask_1_32.txt AC 207 ms 3328 KB
subtask_1_33.txt AC 209 ms 3328 KB
subtask_1_34.txt AC 120 ms 3328 KB
subtask_1_35.txt AC 190 ms 3328 KB
subtask_1_36.txt AC 123 ms 3328 KB
subtask_1_37.txt AC 193 ms 3328 KB