Submission #2791292


Source Code Expand

Copy
#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

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

int main() {
    int N;
    scanf("%d", &N);
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &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;
    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++;
        }
        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]);
    }
    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 1442 Byte
Status AC
Exec Time 54 ms
Memory 3328 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
./Main.cpp:20: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 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 52 ms 3072 KB
subtask_1_03.txt AC 25 ms 1536 KB
subtask_1_04.txt AC 36 ms 2176 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 7 ms 640 KB
subtask_1_07.txt AC 31 ms 2048 KB
subtask_1_08.txt AC 20 ms 1408 KB
subtask_1_09.txt AC 30 ms 1920 KB
subtask_1_10.txt AC 38 ms 2688 KB
subtask_1_11.txt AC 47 ms 2944 KB
subtask_1_12.txt AC 22 ms 1664 KB
subtask_1_13.txt AC 32 ms 2176 KB
subtask_1_14.txt AC 11 ms 896 KB
subtask_1_15.txt AC 7 ms 640 KB
subtask_1_16.txt AC 26 ms 1920 KB
subtask_1_17.txt AC 23 ms 1664 KB
subtask_1_18.txt AC 2 ms 384 KB
subtask_1_19.txt AC 47 ms 3072 KB
subtask_1_20.txt AC 54 ms 3072 KB
subtask_1_21.txt AC 28 ms 1792 KB
subtask_1_22.txt AC 19 ms 1152 KB
subtask_1_23.txt AC 45 ms 2816 KB
subtask_1_24.txt AC 51 ms 3328 KB
subtask_1_25.txt AC 51 ms 3328 KB
subtask_1_26.txt AC 50 ms 3328 KB
subtask_1_27.txt AC 49 ms 3328 KB
subtask_1_28.txt AC 52 ms 3328 KB
subtask_1_29.txt AC 52 ms 3328 KB
subtask_1_30.txt AC 53 ms 3328 KB
subtask_1_31.txt AC 54 ms 3328 KB
subtask_1_32.txt AC 51 ms 3328 KB
subtask_1_33.txt AC 50 ms 3328 KB
subtask_1_34.txt AC 48 ms 3328 KB
subtask_1_35.txt AC 48 ms 3328 KB
subtask_1_36.txt AC 49 ms 3328 KB
subtask_1_37.txt AC 48 ms 3328 KB