結果

問題 No.1676 Coin Trade (Single)
ユーザー abc3abc3
提出日時 2021-09-11 12:31:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 2,202 ms
コンパイル使用メモリ 203,280 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2023-09-04 23:01:56
合計ジャッジ時間 4,914 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 29 ms
7,220 KB
testcase_04 AC 27 ms
6,708 KB
testcase_05 AC 24 ms
6,208 KB
testcase_06 AC 25 ms
6,548 KB
testcase_07 AC 22 ms
5,656 KB
testcase_08 AC 14 ms
4,452 KB
testcase_09 AC 20 ms
5,796 KB
testcase_10 AC 21 ms
5,752 KB
testcase_11 AC 30 ms
7,164 KB
testcase_12 AC 17 ms
4,880 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 37 ms
8,960 KB
testcase_34 AC 38 ms
8,932 KB
testcase_35 AC 38 ms
8,848 KB
testcase_36 AC 38 ms
8,924 KB
testcase_37 AC 37 ms
8,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

   #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef unsigned long long ull;
    using P=pair<ll,ll>;
    const ll INF=1e9;
    const int mod=1e9+7;

    void solve(){
        int n,k;
        cin>>n>>k;
        vector<ll>dp(n);
        vector<ll>a(n);
        vector<vector<ll>>b(n);
        rep(i,n){
            int m;
            cin>>a[i]>>m;
            b[i].resize(m);
            rep(j,m){
                cin>>b[i][j];
                b[i][j]--;
            }
        }
        ll ans=0;
        for(int i=1;i<n;i++){
            chmax(dp[i],dp[i-1]);
            for(int j:b[i]){
                chmax(dp[i],dp[j]+a[i]-a[j]);
            }
        }
        cout<<dp[n-1]<<endl;
    }
 
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve(); 

        return 0;
    }
0