結果

問題 No.1678 Coin Trade (Multiple)
ユーザー merom686merom686
提出日時 2021-09-10 23:21:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 251 ms / 5,000 ms
コード長 711 bytes
コンパイル時間 3,017 ms
コンパイル使用メモリ 223,584 KB
実行使用メモリ 18,300 KB
最終ジャッジ日時 2023-09-02 21:54:21
合計ジャッジ時間 9,499 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 45 ms
12,140 KB
testcase_04 AC 131 ms
15,592 KB
testcase_05 AC 77 ms
17,492 KB
testcase_06 AC 66 ms
16,672 KB
testcase_07 AC 119 ms
14,116 KB
testcase_08 AC 91 ms
13,736 KB
testcase_09 AC 83 ms
17,720 KB
testcase_10 AC 43 ms
9,048 KB
testcase_11 AC 109 ms
15,216 KB
testcase_12 AC 39 ms
9,676 KB
testcase_13 AC 194 ms
17,044 KB
testcase_14 AC 77 ms
11,972 KB
testcase_15 AC 86 ms
14,764 KB
testcase_16 AC 42 ms
15,316 KB
testcase_17 AC 83 ms
18,020 KB
testcase_18 AC 2 ms
4,372 KB
testcase_19 AC 1 ms
4,368 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 2 ms
4,372 KB
testcase_22 AC 2 ms
4,372 KB
testcase_23 AC 2 ms
4,368 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 AC 2 ms
4,368 KB
testcase_26 AC 2 ms
4,372 KB
testcase_27 AC 2 ms
4,368 KB
testcase_28 AC 1 ms
4,368 KB
testcase_29 AC 1 ms
4,368 KB
testcase_30 AC 2 ms
4,368 KB
testcase_31 AC 1 ms
4,368 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 2 ms
4,368 KB
testcase_34 AC 2 ms
4,368 KB
testcase_35 AC 2 ms
4,372 KB
testcase_36 AC 2 ms
4,372 KB
testcase_37 AC 2 ms
4,368 KB
testcase_38 AC 2 ms
4,372 KB
testcase_39 AC 1 ms
4,368 KB
testcase_40 AC 2 ms
4,372 KB
testcase_41 AC 1 ms
4,372 KB
testcase_42 AC 1 ms
4,372 KB
testcase_43 AC 1 ms
4,372 KB
testcase_44 AC 2 ms
4,368 KB
testcase_45 AC 2 ms
4,372 KB
testcase_46 AC 2 ms
4,368 KB
testcase_47 AC 2 ms
4,372 KB
testcase_48 AC 251 ms
17,904 KB
testcase_49 AC 242 ms
17,856 KB
testcase_50 AC 243 ms
18,052 KB
testcase_51 AC 244 ms
18,148 KB
testcase_52 AC 235 ms
17,988 KB
testcase_53 AC 243 ms
18,300 KB
testcase_54 AC 245 ms
17,892 KB
testcase_55 AC 244 ms
17,928 KB
testcase_56 AC 240 ms
17,940 KB
testcase_57 AC 239 ms
17,872 KB
testcase_58 AC 135 ms
14,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/mincostflow>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    atcoder::mcf_graph<int, ll> g(n);

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];

        int m;
        cin >> m;

        if (i == 0) continue;

        g.add_edge(i - 1, i, k, 1 << 30);

        for (int j = 0; j < m; j++) {
            int b;
            cin >> b;
            b--;

            g.add_edge(b, i, 1, ((ll)(i - b) << 30) - a[i] + a[b]);
        }
    }
    auto p = g.flow(0, n - 1, k);
    cout << ((ll)((n - 1) * k) << 30) - p.second << endl;

    return 0;
}
0