結果

問題 No.1676 Coin Trade (Single)
ユーザー ぷらぷら
提出日時 2021-09-10 21:49:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 596 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 204,040 KB
実行使用メモリ 8,464 KB
最終ジャッジ日時 2023-09-02 16:52:57
合計ジャッジ時間 4,994 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 69 ms
6,764 KB
testcase_04 AC 61 ms
6,188 KB
testcase_05 AC 57 ms
6,188 KB
testcase_06 AC 58 ms
5,872 KB
testcase_07 AC 49 ms
5,076 KB
testcase_08 AC 32 ms
4,376 KB
testcase_09 AC 47 ms
5,252 KB
testcase_10 AC 50 ms
5,360 KB
testcase_11 AC 70 ms
7,024 KB
testcase_12 AC 40 ms
4,648 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 90 ms
8,464 KB
testcase_34 AC 89 ms
8,248 KB
testcase_35 AC 91 ms
8,332 KB
testcase_36 AC 90 ms
8,264 KB
testcase_37 AC 90 ms
8,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long inf = 1001001001001001001;

int main() {
    int N,K;
    cin >> N >> K;
    vector<int>A(N);
    vector<vector<int>>B(N);
    vector<long long>dp(N+1,-inf);
    dp[N] = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        int M;
        cin >> M;
        dp[i] = max(dp[i],dp[N]-A[i]);
        B[i].resize(M);
        for(int j = 0; j < M; j++) {
            cin >> B[i][j];
            B[i][j]--;
            dp[i] = max(dp[i],dp[B[i][j]]);
        }
        dp[N] = max(dp[N],dp[i]+A[i]);
    }
    cout << dp[N] << endl;
}
0