結果

問題 No.1676 Coin Trade (Single)
ユーザー mtrhmtrh
提出日時 2021-09-19 17:21:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 170,540 KB
実行使用メモリ 9,260 KB
最終ジャッジ日時 2023-09-14 13:28:55
合計ジャッジ時間 4,421 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 72 ms
7,320 KB
testcase_04 AC 66 ms
6,688 KB
testcase_05 AC 61 ms
6,424 KB
testcase_06 AC 61 ms
6,404 KB
testcase_07 AC 52 ms
5,688 KB
testcase_08 AC 34 ms
4,384 KB
testcase_09 AC 51 ms
5,368 KB
testcase_10 AC 53 ms
5,628 KB
testcase_11 AC 73 ms
7,532 KB
testcase_12 AC 42 ms
4,896 KB
testcase_13 AC 2 ms
4,376 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,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 91 ms
9,260 KB
testcase_34 AC 92 ms
9,064 KB
testcase_35 AC 93 ms
9,176 KB
testcase_36 AC 92 ms
9,064 KB
testcase_37 AC 93 ms
9,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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