結果

問題 No.2854 -1 Subsequence
ユーザー t98slidert98slider
提出日時 2024-08-25 13:41:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 203,128 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-25 13:41:37
合計ジャッジ時間 3,876 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
6,812 KB
testcase_01 AC 24 ms
6,940 KB
testcase_02 AC 22 ms
6,940 KB
testcase_03 AC 13 ms
6,940 KB
testcase_04 AC 25 ms
6,940 KB
testcase_05 AC 17 ms
6,944 KB
testcase_06 AC 10 ms
6,944 KB
testcase_07 AC 23 ms
6,944 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 18 ms
6,940 KB
testcase_10 AC 29 ms
6,944 KB
testcase_11 AC 29 ms
6,944 KB
testcase_12 AC 30 ms
6,944 KB
testcase_13 AC 26 ms
6,944 KB
testcase_14 AC 27 ms
6,940 KB
testcase_15 AC 26 ms
6,944 KB
testcase_16 AC 27 ms
6,944 KB
testcase_17 AC 28 ms
6,944 KB
testcase_18 AC 29 ms
6,940 KB
testcase_19 AC 29 ms
6,940 KB
testcase_20 AC 28 ms
6,940 KB
testcase_21 AC 27 ms
6,944 KB
testcase_22 AC 28 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
6,944 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
6,940 KB
testcase_31 WA -
testcase_32 AC 2 ms
6,940 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 1 ms
6,944 KB
testcase_37 WA -
testcase_38 AC 1 ms
6,944 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    constexpr ll INF = (1ll << 60);
    vector<array<ll,2>> dp(n + 1, array<ll,2>({-INF, -INF}));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        int v;
        cin >> v;
        for(int j = 0; j < 2; j++){
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j ^ 1] = max(dp[i + 1][j ^ 1], dp[i][j] + (j == 0 ? -v : v));
        }
    }
    cout << max(dp[n][0], dp[n][1]) << '\n';
}
0