Submission #3900997


Source Code Expand

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

int64_t dp[2001][2001][2];
void chmax(int64_t& a, int64_t b){
    a = max(a, b);
}

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

    assert(N<=2000);

    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            if(i<N){
                chmax(dp[i+1][j][0], dp[i][j][0] + X[i+1] - X[i]);
                chmax(dp[i+1][j][0], dp[i][j][1] + X[i+1] + Y[j]);
            }
            if(j<N){
                chmax(dp[i][j+1][1], dp[i][j][1] + Y[j+1] - Y[j]);
                chmax(dp[i][j+1][1], dp[i][j][0] + X[i] + Y[j+1]);
            }
        }
    }
    int64_t ans = 0;
    for(int i=0; i<=N; i++) for(int k=0; k<2; k++){
        chmax(ans, dp[i][N-i][k]);
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task B - Tree Burning
User betrue12
Language C++14 (GCC 5.4.1)
Score 300
Code Size 932 Byte
Status RE
Exec Time 102 ms
Memory 62848 KiB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 300 / 300 0 / 500
Status
AC × 3
AC × 29
AC × 29
RE × 14
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 38 ms 62848 KiB
02.txt AC 38 ms 62720 KiB
03.txt AC 39 ms 62720 KiB
04.txt AC 39 ms 62848 KiB
05.txt AC 39 ms 62848 KiB
06.txt AC 39 ms 62720 KiB
07.txt AC 39 ms 62720 KiB
08.txt AC 39 ms 62848 KiB
09.txt AC 39 ms 62848 KiB
10.txt AC 39 ms 62720 KiB
11.txt AC 39 ms 62720 KiB
12.txt AC 39 ms 62848 KiB
13.txt AC 39 ms 62848 KiB
14.txt AC 39 ms 62720 KiB
15.txt AC 39 ms 62720 KiB
16.txt AC 39 ms 62848 KiB
17.txt AC 39 ms 62848 KiB
18.txt AC 39 ms 62720 KiB
19.txt AC 38 ms 62720 KiB
20.txt AC 39 ms 62848 KiB
21.txt AC 39 ms 62848 KiB
22.txt AC 38 ms 62720 KiB
23.txt AC 38 ms 62720 KiB
24.txt AC 39 ms 62848 KiB
25.txt RE 101 ms 256 KiB
26.txt RE 100 ms 256 KiB
27.txt RE 100 ms 256 KiB
28.txt RE 102 ms 256 KiB
29.txt RE 101 ms 256 KiB
30.txt RE 100 ms 256 KiB
31.txt RE 100 ms 256 KiB
32.txt RE 101 ms 256 KiB
33.txt RE 100 ms 256 KiB
34.txt RE 101 ms 256 KiB
35.txt RE 100 ms 256 KiB
36.txt RE 99 ms 256 KiB
37.txt RE 100 ms 256 KiB
38.txt RE 101 ms 256 KiB
39.txt AC 1 ms 256 KiB
40.txt AC 1 ms 256 KiB
s1.txt AC 1 ms 256 KiB
s2.txt AC 1 ms 256 KiB
s3.txt AC 1 ms 256 KiB