結果

問題 No.2542 Yokan for Two
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-12-21 10:08:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 846 bytes
コンパイル時間 2,276 ms
コンパイル使用メモリ 211,672 KB
実行使用メモリ 716,020 KB
最終ジャッジ日時 2023-12-21 10:08:50
合計ジャッジ時間 32,422 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 329 ms
228,244 KB
testcase_04 AC 209 ms
138,368 KB
testcase_05 AC 542 ms
351,776 KB
testcase_06 AC 24 ms
17,920 KB
testcase_07 MLE -
testcase_08 AC 284 ms
178,408 KB
testcase_09 MLE -
testcase_10 AC 122 ms
78,336 KB
testcase_11 AC 151 ms
97,664 KB
testcase_12 AC 393 ms
264,616 KB
testcase_13 AC 101 ms
66,048 KB
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 AC 606 ms
387,208 KB
testcase_20 AC 563 ms
356,352 KB
testcase_21 AC 557 ms
357,632 KB
testcase_22 AC 602 ms
368,768 KB
testcase_23 AC 612 ms
371,584 KB
testcase_24 AC 84 ms
59,432 KB
testcase_25 AC 126 ms
87,620 KB
testcase_26 AC 125 ms
87,620 KB
testcase_27 AC 135 ms
94,696 KB
testcase_28 AC 146 ms
101,648 KB
testcase_29 AC 280 ms
193,108 KB
testcase_30 MLE -
testcase_31 MLE -
testcase_32 MLE -
testcase_33 MLE -
testcase_34 MLE -
testcase_35 MLE -
testcase_36 MLE -
testcase_37 MLE -
testcase_38 MLE -
testcase_39 MLE -
testcase_40 MLE -
testcase_41 MLE -
testcase_42 MLE -
testcase_43 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int L, N, ans=1e9;
    cin >> L >> N;
    vector<int> x(N+1);
    for (int i=1; i<=N; i++) cin >> x[i];

    vector dp(N+1, vector(L+1, vector<bool>(2)));
    dp[0][0][0] = 1;
    for (int i=1; i<=N; i++){
        for (int j=0; j<=L; j++){
            if (j-(x[i]-x[i-1])>=0){
                dp[i][j][0] = dp[i][j][0] | dp[i-1][j-(x[i]-x[i-1])][0];
                dp[i][j][1] = dp[i][j][1] |  dp[i-1][j-(x[i]-x[i-1])][0];
            }
            dp[i][j][0] = dp[i][j][0] | dp[i-1][j][1];
            dp[i][j][1] = dp[i][j][1] | dp[i-1][j][1];
        }
    }

    for (int i=0; i<=L; i++){
        if (dp[N][i][0]) ans = min(ans, abs(i-(L-i)));
    }

    cout << ans << endl;

    return 0;
}
0