Submission #3895457


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

void chmax(int64_t& a, int64_t b){
    a = max(a, b);
}

const int M = 200001;
int L, N;
int64_t X[M], Y[M], Xs[M], Ys[M];

int main(){
    cin >> L >> N;
    for(int i=1; i<=N; i++){
        cin >> X[i];
        Y[N+1-i] = L - X[i];
    }
    for(int i=1; i<=N; i++){
        Xs[i] = Xs[i-1] + X[i];
        Ys[i] = Ys[i-1] + Y[i];
    }

    const int dx[2] = {1, 0};
    const int dy[2] = {0, 1};
    int64_t ans = 0;
    for(int d=0; d<=N; d++){
        int xt = d, yt = N-d;
        for(int k1=0; k1<2; k1++){
            for(int k2=0; k2<2; k2++){
                int cx = min(xt, yt + (- dy[k1] - dy[k2] + dx[k1] + dx[k2]) / 2);
                int cy = min(yt, xt + (- dx[k1] - dx[k2] + dy[k1] + dy[k2]) / 2);
                if(cx < 0 || cy < 0) continue;

                int64_t result = 0;
                result += (Xs[xt] - Xs[xt-cx]) * 2;
                result += (Ys[yt] - Ys[yt-cy]) * 2;
                result -= (k2 ? Y[yt] : X[xt]);
                chmax(ans, result);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task B - Tree Burning
User betrue12
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1150 Byte
Status AC
Exec Time 113 ms
Memory 6528 KiB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 300 / 300 500 / 500
Status
AC × 3
AC × 29
AC × 43
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
Subtask1 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 39.txt, 40.txt, s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 3 ms 4352 KiB
02.txt AC 3 ms 4352 KiB
03.txt AC 3 ms 4352 KiB
04.txt AC 3 ms 4352 KiB
05.txt AC 3 ms 4352 KiB
06.txt AC 3 ms 4352 KiB
07.txt AC 3 ms 4352 KiB
08.txt AC 3 ms 4352 KiB
09.txt AC 3 ms 4352 KiB
10.txt AC 3 ms 4352 KiB
11.txt AC 3 ms 4352 KiB
12.txt AC 3 ms 4352 KiB
13.txt AC 3 ms 4352 KiB
14.txt AC 3 ms 4352 KiB
15.txt AC 3 ms 4352 KiB
16.txt AC 3 ms 4352 KiB
17.txt AC 3 ms 4352 KiB
18.txt AC 3 ms 4352 KiB
19.txt AC 3 ms 4352 KiB
20.txt AC 3 ms 4352 KiB
21.txt AC 3 ms 4352 KiB
22.txt AC 2 ms 4352 KiB
23.txt AC 2 ms 4352 KiB
24.txt AC 2 ms 4352 KiB
25.txt AC 108 ms 6528 KiB
26.txt AC 112 ms 6528 KiB
27.txt AC 109 ms 6528 KiB
28.txt AC 112 ms 6528 KiB
29.txt AC 110 ms 6528 KiB
30.txt AC 109 ms 6528 KiB
31.txt AC 103 ms 6528 KiB
32.txt AC 110 ms 6528 KiB
33.txt AC 110 ms 6528 KiB
34.txt AC 94 ms 6528 KiB
35.txt AC 110 ms 6528 KiB
36.txt AC 108 ms 6528 KiB
37.txt AC 113 ms 6528 KiB
38.txt AC 82 ms 6528 KiB
39.txt AC 2 ms 4352 KiB
40.txt AC 2 ms 4352 KiB
s1.txt AC 2 ms 4352 KiB
s2.txt AC 2 ms 4352 KiB
s3.txt AC 2 ms 4352 KiB