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

Submission #2774019

Source Code Expand

Copy
```#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

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

ll ans = 1LL << 62;
for(int j = 1; j < N - 2; j++) {
int i1 = lower_bound(acc.begin(), acc.begin() + j + 1, acc[j + 1] / 2) - acc.begin() - 1;
int i2 = i1 - 1;

int ss = acc[N] - acc[j + 1];
int k1 = lower_bound(acc.begin() + j + 1, acc.end(), ss / 2 + acc[j + 1]) - acc.begin() - 1;
int k2 = k1 - 1;

vector<int> I, K;
I.push_back(i1);
K.push_back(k1);

if (i2 >= 0) {
I.push_back(i2);
}

if (k2 > j) {
K.push_back(k2);
}

for(int u = 0; u < I.size(); u++) {
for(int v = 0; v < K.size(); v++) {
int i = I[u];
int k = K[v];

vector<ll> area;
ll areaB = acc[i + 1];
ll areaC = acc[j + 1] - acc[i + 1];
ll areaD = acc[k + 1] - acc[j + 1];
ll areaE = acc[N] - acc[k + 1];

area.push_back(areaB);
area.push_back(areaC);
area.push_back(areaE);

sort(area.begin(), area.end());
ans = min(ans, area.back() - area[0]);
}
}

}
cout << ans << endl;
return 0;
}```

#### Submission Info

Submission Time 2018-07-01 21:39:44+0900 D - Equal Cut kakira C++14 (GCC 5.4.1) 0 2214 Byte RE 226 ms 3328 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
 AC × 1 RE × 2
 AC × 27 WA × 12 RE × 4
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt RE 97 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt RE 97 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt WA 170 ms 3072 KB
subtask_1_03.txt WA 80 ms 1536 KB
subtask_1_04.txt WA 119 ms 2176 KB
subtask_1_05.txt WA 1 ms 256 KB
subtask_1_06.txt AC 18 ms 640 KB
subtask_1_07.txt WA 111 ms 2048 KB
subtask_1_08.txt AC 52 ms 1408 KB
subtask_1_09.txt WA 107 ms 1920 KB
subtask_1_10.txt AC 163 ms 2688 KB
subtask_1_11.txt WA 170 ms 3072 KB
subtask_1_12.txt AC 63 ms 1664 KB
subtask_1_13.txt WA 110 ms 2176 KB
subtask_1_14.txt AC 42 ms 896 KB
subtask_1_15.txt AC 25 ms 640 KB
subtask_1_16.txt AC 65 ms 1920 KB
subtask_1_17.txt AC 90 ms 1664 KB
subtask_1_18.txt AC 5 ms 384 KB
subtask_1_19.txt AC 178 ms 3072 KB
subtask_1_20.txt WA 174 ms 3072 KB
subtask_1_21.txt WA 88 ms 1792 KB
subtask_1_22.txt WA 59 ms 1152 KB
subtask_1_23.txt WA 152 ms 2816 KB
subtask_1_24.txt AC 144 ms 3328 KB
subtask_1_25.txt AC 148 ms 3328 KB
subtask_1_26.txt AC 169 ms 3328 KB
subtask_1_27.txt AC 206 ms 3328 KB
subtask_1_28.txt AC 226 ms 3328 KB
subtask_1_29.txt AC 217 ms 3328 KB
subtask_1_30.txt AC 215 ms 3328 KB
subtask_1_31.txt AC 206 ms 3328 KB
subtask_1_32.txt AC 202 ms 3328 KB
subtask_1_33.txt AC 203 ms 3328 KB
subtask_1_34.txt AC 122 ms 3328 KB
subtask_1_35.txt AC 192 ms 3328 KB
subtask_1_36.txt AC 124 ms 3328 KB
subtask_1_37.txt AC 196 ms 3328 KB