結果

問題 No.1676 Coin Trade (Single)
ユーザー Manuel1024
提出日時 2022-09-06 05:30:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 76,384 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-11-21 06:40:43
合計ジャッジ時間 4,181 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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 x; cin >> x;
            x--;
            b[i].emplace_back(x);
        }
    }

    vector<ll> dp(n+1, 0);
    for(int i = 0; i < n; i++){
        dp[i+1] = dp[i];
        for(auto &it: b[i]){
            dp[i+1] = max(dp[i+1], dp[it]+a[i]-a[it]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}
0