結果

問題 No.1676 Coin Trade (Single)
ユーザー nawawannawawan
提出日時 2021-09-11 01:12:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 720 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 206,604 KB
実行使用メモリ 14,636 KB
最終ジャッジ日時 2023-09-03 16:26:03
合計ジャッジ時間 4,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> A(N), M(N);
    vector<vector<int>> B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> M[i];
        B[i].resize(M[i]);
        for(int j = 0; j < M[i]; j++) {
            cin >> B[i][j];
            B[i][j]--;
        }
    }
    vector<vector<long long>> dp(N, vector<long long>(2));
    dp[0][0] = 0;
    dp[0][1] = -A[0];
    for(int i = 1; i < N; i++){
        for(int j = 0; j < M[i]; j++){
            dp[i][0] = max(dp[i][0], A[i] + dp[B[i][j]][1]);
            dp[i][0] = max(dp[i][0], dp[i - 1][0]);
        }
        dp[i][1] = dp[i][0] - A[i];
    }
    cout << dp[N - 1][0] << endl;
}
0