結果

問題 No.1676 Coin Trade (Single)
ユーザー mamimume____momamimume____mo
提出日時 2021-09-10 23:53:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 171,840 KB
実行使用メモリ 8,420 KB
最終ジャッジ日時 2023-09-03 00:47:23
合計ジャッジ時間 5,934 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 70 ms
6,764 KB
testcase_04 AC 64 ms
6,604 KB
testcase_05 AC 59 ms
5,908 KB
testcase_06 AC 60 ms
5,896 KB
testcase_07 AC 51 ms
5,472 KB
testcase_08 AC 34 ms
4,380 KB
testcase_09 AC 50 ms
5,280 KB
testcase_10 AC 53 ms
5,376 KB
testcase_11 AC 72 ms
6,980 KB
testcase_12 AC 42 ms
4,628 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,388 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 89 ms
8,392 KB
testcase_34 AC 90 ms
8,280 KB
testcase_35 AC 90 ms
8,244 KB
testcase_36 AC 90 ms
8,420 KB
testcase_37 AC 89 ms
8,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000100;
const ll INFL = 2e18;
template <class T>bool chmin(T &a, T b){ if (a > b) { a = b; return true;} else return false;}
template <class T>bool chmax(T &a, T b){ if (a < b) { a = b; return true;} else return false;}

int main() {
    int N,K;
    cin >> N >> K;

    vector<int> A(N);
    vector<vector<int>> B(N);
    for (int i = 0;i < N;i++) {
        cin >> A[i];
        int M;
        cin >> M;
        for (int j = 0;j < M;j++) {
            int b;
            cin >> b;
            b--;
            B[i].push_back(b);
        }
    }


    vector<ll> dp(N,0);
    for (int i = 1;i < N;i++) {
        chmax(dp[i],dp[i-1]);
        for (int j = 0;j < B[i].size();j++) {
            chmax(dp[i],dp[B[i][j]] + A[i] - A[B[i][j]]);
        }
    }

    cout << dp[N-1] << endl;
}
0