結果

問題 No.1676 Coin Trade (Single)
ユーザー otoshigootoshigo
提出日時 2021-09-17 19:10:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,193 bytes
コンパイル時間 5,185 ms
コンパイル使用メモリ 263,176 KB
実行使用メモリ 8,852 KB
最終ジャッジ日時 2023-09-12 04:27:49
合計ジャッジ時間 8,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 83 ms
7,032 KB
testcase_04 AC 76 ms
6,708 KB
testcase_05 AC 70 ms
6,176 KB
testcase_06 AC 73 ms
6,468 KB
testcase_07 AC 58 ms
5,652 KB
testcase_08 AC 40 ms
4,748 KB
testcase_09 AC 57 ms
5,652 KB
testcase_10 AC 62 ms
5,952 KB
testcase_11 AC 84 ms
7,312 KB
testcase_12 AC 47 ms
5,208 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 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,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 104 ms
8,604 KB
testcase_34 AC 102 ms
8,592 KB
testcase_35 AC 101 ms
8,560 KB
testcase_36 AC 103 ms
8,852 KB
testcase_37 AC 106 ms
8,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;  using vvi = vector<vi>;
using vl = vector<ll>;   using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>;
using vm = vector<mint>; using vvm = vector<vm>;
using vpi = vector<pii>; using vvpi = vector<vpi>;
using vpl = vector<pll>; using vvpl = vector<vpl>;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
#define rep(i,m,n) for (int i = m; i < (int)(n); i++)
#define rrep(i,m,n) for (int i = m; i > (int)(n); i--)

int main(){
    int n,k; cin >> n >> k;
    vi A(n);
    vvpi G(n);
    rep(i,0,n){
        int a,m; cin >> a >> m;
        A[i] = a;
        rep(j,0,m){
            int b; cin >> b; --b;
            G[b].push_back({i,a-A[b]});
        }
    }
    vl dp(n+1);
    rep(i,0,n){
        dp[i+1] = max(dp[i],dp[i+1]);
        for (auto p:G[i]){
            int j = p.first, b = p.second;
            dp[j] = max(dp[i]+b,dp[j]);
        }
    }
    cout << dp[n] << endl;
}
0