Submission #3903311


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    int l, n;
    cin >> l >> n;
    vector<int> xl(n+1, 0);
    vector<int> xr(n+1, 0);
    REP(i, n) {
        cin >> xl[i+1];
        xr[n-i] = l - xl[i+1];
    }

    if (n == 1) {
        cout << max(xl[1], xr[1]) << endl;
        return 0;
    }

    // 部分点
    ll dp[n+1][n+1][2] = {};

    REP(l, n) {
        REP(r, n) {
            REP(x, 2) {
                if (l > 0) {
                    chmax(dp[l][r][0], dp[l-1][r][0] + xl[l] - xl[l-1]);
                    chmax(dp[l][r][0], dp[l-1][r][1] + xl[l] + xr[r]);
                }
                if (r > 0) {
                    chmax(dp[l][r][1], dp[l][r-1][0] + xl[l] + xr[r]);
                    chmax(dp[l][r][1], dp[l][r-1][1] + xr[r] - xr[r-1]);
                }
            }
        }
    }

    ll ans = 0;
    REP(x, n) {
        chmax(ans, dp[x][n-x][0]);
        chmax(ans, dp[x][n-x][1]);
    }
    cout << ans << endl;
    
}

Submission Info

Submission Time
Task B - Tree Burning
User ganmodokix
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1407 Byte
Status RE
Exec Time 180 ms
Memory 62848 KB

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 47 ms 62720 KB
02.txt AC 47 ms 62720 KB
03.txt AC 47 ms 62592 KB
04.txt AC 47 ms 62848 KB
05.txt AC 47 ms 62720 KB
06.txt AC 47 ms 62720 KB
07.txt AC 47 ms 62592 KB
08.txt AC 47 ms 62848 KB
09.txt AC 47 ms 62720 KB
10.txt AC 47 ms 62720 KB
11.txt AC 47 ms 62592 KB
12.txt AC 47 ms 62848 KB
13.txt AC 47 ms 62720 KB
14.txt AC 47 ms 62720 KB
15.txt AC 47 ms 62592 KB
16.txt AC 47 ms 62848 KB
17.txt AC 47 ms 62720 KB
18.txt AC 47 ms 62720 KB
19.txt AC 47 ms 62592 KB
20.txt AC 47 ms 62848 KB
21.txt AC 47 ms 62720 KB
22.txt AC 47 ms 62720 KB
23.txt AC 47 ms 62592 KB
24.txt AC 47 ms 62848 KB
25.txt RE 178 ms 1792 KB
26.txt RE 178 ms 1792 KB
27.txt RE 177 ms 1792 KB
28.txt RE 178 ms 1792 KB
29.txt RE 178 ms 1792 KB
30.txt RE 174 ms 1792 KB
31.txt RE 173 ms 1792 KB
32.txt RE 176 ms 1792 KB
33.txt RE 177 ms 1792 KB
34.txt RE 165 ms 1792 KB
35.txt RE 180 ms 1792 KB
36.txt RE 174 ms 1792 KB
37.txt RE 180 ms 1792 KB
38.txt RE 160 ms 1792 KB
39.txt AC 1 ms 256 KB
40.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB