Submission #2791307


Source Code Expand

Copy
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;

int N;
ll A[200001];
ll acc[200002];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    for (int i = 0; i < N; i++) {
        acc[i + 1] = acc[i] + A[i];
    }
    ll ans = 1LL << 62;
    int i = 1, k = 3;
    for(int j = 2; j < N - 1; j++) {
        while(i + 1 < j) {
            ll newarea = acc[i + 1] - acc[0];
            ll area = acc[i] - acc[0];
            if (abs(newarea - (acc[j] - newarea)) > abs(area - (acc[j] - area))) break;
            i++;
        }
        while(k + 1 < N) {
            ll newarea = acc[k + 1] - acc[j];
            ll area = acc[k] - acc[j];
            if (abs(newarea - (acc[N] - acc[j] - newarea)) > abs(area - (acc[N] - acc[j] - area))) break;
            k++;
        }
        ll mi = min(min(acc[i], acc[j] - acc[i]), min(acc[k] - acc[j], acc[N] - acc[k]));
        ll ma = max(max(acc[i], acc[j] - acc[i]), max(acc[k] - acc[j], acc[N] - acc[k]));        
        ans = min(ans, ma - mi);
    }
    printf("%lld\n", ans);
    return 0;
}

Submission Info

Submission Time
Task D - Equal Cut
User kakira
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1167 Byte
Status AC
Exec Time 26 ms
Memory 3328 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
./Main.cpp:14:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &A[i]);
                             ^

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
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_30.txt, subtask_1_31.txt, subtask_1_32.txt, subtask_1_33.txt, subtask_1_34.txt, subtask_1_35.txt, subtask_1_36.txt, subtask_1_37.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 128 KB
sample_02.txt AC 1 ms 128 KB
sample_03.txt AC 1 ms 128 KB
subtask_1_01.txt AC 1 ms 128 KB
subtask_1_02.txt AC 26 ms 2944 KB
subtask_1_03.txt AC 11 ms 1536 KB
subtask_1_04.txt AC 18 ms 2176 KB
subtask_1_05.txt AC 1 ms 128 KB
subtask_1_06.txt AC 3 ms 512 KB
subtask_1_07.txt AC 14 ms 1920 KB
subtask_1_08.txt AC 8 ms 1280 KB
subtask_1_09.txt AC 13 ms 1920 KB
subtask_1_10.txt AC 16 ms 2560 KB
subtask_1_11.txt AC 21 ms 2944 KB
subtask_1_12.txt AC 10 ms 1536 KB
subtask_1_13.txt AC 14 ms 2048 KB
subtask_1_14.txt AC 4 ms 768 KB
subtask_1_15.txt AC 3 ms 512 KB
subtask_1_16.txt AC 10 ms 1792 KB
subtask_1_17.txt AC 9 ms 1536 KB
subtask_1_18.txt AC 1 ms 256 KB
subtask_1_19.txt AC 18 ms 3072 KB
subtask_1_20.txt AC 26 ms 3072 KB
subtask_1_21.txt AC 12 ms 1664 KB
subtask_1_22.txt AC 9 ms 1152 KB
subtask_1_23.txt AC 20 ms 2688 KB
subtask_1_24.txt AC 22 ms 3328 KB
subtask_1_25.txt AC 22 ms 3328 KB
subtask_1_26.txt AC 21 ms 3328 KB
subtask_1_27.txt AC 21 ms 3328 KB
subtask_1_28.txt AC 21 ms 3328 KB
subtask_1_29.txt AC 22 ms 3328 KB
subtask_1_30.txt AC 22 ms 3328 KB
subtask_1_31.txt AC 22 ms 3328 KB
subtask_1_32.txt AC 22 ms 3328 KB
subtask_1_33.txt AC 22 ms 3328 KB
subtask_1_34.txt AC 19 ms 3328 KB
subtask_1_35.txt AC 20 ms 3328 KB
subtask_1_36.txt AC 18 ms 3328 KB
subtask_1_37.txt AC 19 ms 3328 KB