結果

問題 No.1676 Coin Trade (Single)
ユーザー auauaauaua
提出日時 2021-09-10 22:36:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 169,836 KB
実行使用メモリ 9,840 KB
最終ジャッジ日時 2023-09-02 19:12:04
合計ジャッジ時間 4,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 72 ms
7,852 KB
testcase_04 AC 66 ms
7,236 KB
testcase_05 AC 61 ms
7,024 KB
testcase_06 AC 61 ms
7,092 KB
testcase_07 AC 53 ms
6,176 KB
testcase_08 AC 35 ms
4,856 KB
testcase_09 AC 52 ms
6,172 KB
testcase_10 AC 54 ms
6,164 KB
testcase_11 AC 74 ms
8,168 KB
testcase_12 AC 43 ms
5,424 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 1 ms
4,368 KB
testcase_15 AC 1 ms
4,368 KB
testcase_16 AC 1 ms
4,368 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 2 ms
4,368 KB
testcase_21 AC 1 ms
4,372 KB
testcase_22 AC 1 ms
4,368 KB
testcase_23 AC 1 ms
4,368 KB
testcase_24 AC 1 ms
4,372 KB
testcase_25 AC 2 ms
4,372 KB
testcase_26 AC 2 ms
4,368 KB
testcase_27 AC 1 ms
4,372 KB
testcase_28 AC 1 ms
4,368 KB
testcase_29 AC 1 ms
4,372 KB
testcase_30 AC 2 ms
4,372 KB
testcase_31 AC 1 ms
4,372 KB
testcase_32 AC 1 ms
4,368 KB
testcase_33 AC 91 ms
9,840 KB
testcase_34 AC 92 ms
9,732 KB
testcase_35 AC 91 ms
9,596 KB
testcase_36 AC 92 ms
9,548 KB
testcase_37 AC 92 ms
9,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<random>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
//#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=1000000;
const double PI=acos(-1.0);
typedef vector<vector<ll> > mat;
typedef vector<ll> vec;



void solve(){
    ll n,k;cin>>n>>k;
    vector<ll>a(n),m(n);
    vector<vector<ll> >b(n);
    rep(i,n){
        cin>>a[i]>>m[i];
        rep(j,m[i]){
            ll c;cin>>c;
            c--;
            b[i].pb(c);
        }
    }
    vector<ll>dp(n,-1);
    ll ans=0;
    rep(i,n){
        dp[i]=0;
        if(i)dp[i]=max(dp[i],dp[i-1]);
        rep(j,m[i]){
            dp[i]=max(dp[i],dp[b[i][j]] + a[i]-a[b[i][j]]);
        }
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}

signed main(){
    solve();
}
0