結果

問題 No.1678 Coin Trade (Multiple)
ユーザー norikamenorikame
提出日時 2021-09-11 13:07:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 248 ms / 5,000 ms
コード長 991 bytes
コンパイル時間 4,814 ms
コンパイル使用メモリ 278,680 KB
実行使用メモリ 20,540 KB
最終ジャッジ日時 2023-09-04 23:51:12
合計ジャッジ時間 11,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 56 ms
13,336 KB
testcase_04 AC 144 ms
17,460 KB
testcase_05 AC 99 ms
19,740 KB
testcase_06 AC 88 ms
18,648 KB
testcase_07 AC 130 ms
14,112 KB
testcase_08 AC 103 ms
15,020 KB
testcase_09 AC 105 ms
19,624 KB
testcase_10 AC 48 ms
9,456 KB
testcase_11 AC 119 ms
16,724 KB
testcase_12 AC 45 ms
9,956 KB
testcase_13 AC 199 ms
19,000 KB
testcase_14 AC 88 ms
12,900 KB
testcase_15 AC 100 ms
16,528 KB
testcase_16 AC 62 ms
17,436 KB
testcase_17 AC 107 ms
20,000 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 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,384 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 242 ms
20,268 KB
testcase_49 AC 241 ms
20,252 KB
testcase_50 AC 248 ms
20,540 KB
testcase_51 AC 242 ms
20,200 KB
testcase_52 AC 238 ms
20,196 KB
testcase_53 AC 244 ms
20,248 KB
testcase_54 AC 239 ms
20,372 KB
testcase_55 AC 239 ms
20,496 KB
testcase_56 AC 238 ms
19,980 KB
testcase_57 AC 237 ms
20,272 KB
testcase_58 AC 153 ms
16,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

// 

const ll BIAS = (ll)(1e9);

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n), m(n);
    vector<vector<int>> b(n);
    rep(i, n) {
        cin >> a[i] >> m[i];
        vector<int> bi(m[i]);
        rep(j, m[i]) {
            cin >> bi[j];
            bi[j]--;
        }
        b[i] = bi;
    }
    mcf_graph<int, ll> g(n);
    rep(i, n-1) g.add_edge(i, i+1, k, BIAS);
    rep(i, n) rep(j, m[i]) g.add_edge(b[i][j], i, 1, (a[b[i][j]]-a[i])+(i-b[i][j])*BIAS);
    auto p = g.flow(0, n-1, k);
    ll res = -(p.second - (n-1) * k * BIAS);
    cout << res << endl;
    return 0;
}
0