結果

問題 No.1678 Coin Trade (Multiple)
ユーザー stoqstoq
提出日時 2021-08-02 02:44:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 300 ms / 5,000 ms
コード長 621 bytes
コンパイル時間 5,219 ms
コンパイル使用メモリ 278,660 KB
実行使用メモリ 20,528 KB
最終ジャッジ日時 2023-09-02 15:01:26
合計ジャッジ時間 12,065 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 59 ms
13,004 KB
testcase_04 AC 167 ms
17,632 KB
testcase_05 AC 111 ms
19,772 KB
testcase_06 AC 96 ms
18,928 KB
testcase_07 AC 148 ms
15,064 KB
testcase_08 AC 111 ms
15,340 KB
testcase_09 AC 115 ms
19,848 KB
testcase_10 AC 49 ms
9,240 KB
testcase_11 AC 133 ms
17,260 KB
testcase_12 AC 48 ms
9,800 KB
testcase_13 AC 241 ms
19,640 KB
testcase_14 AC 92 ms
13,056 KB
testcase_15 AC 110 ms
16,568 KB
testcase_16 AC 65 ms
16,872 KB
testcase_17 AC 116 ms
20,112 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 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 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,384 KB
testcase_38 AC 2 ms
4,384 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,384 KB
testcase_41 AC 1 ms
4,384 KB
testcase_42 AC 1 ms
4,384 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,384 KB
testcase_48 AC 293 ms
20,396 KB
testcase_49 AC 300 ms
20,500 KB
testcase_50 AC 290 ms
20,208 KB
testcase_51 AC 290 ms
20,512 KB
testcase_52 AC 295 ms
20,308 KB
testcase_53 AC 300 ms
20,200 KB
testcase_54 AC 300 ms
20,408 KB
testcase_55 AC 289 ms
20,528 KB
testcase_56 AC 289 ms
20,380 KB
testcase_57 AC 290 ms
20,304 KB
testcase_58 AC 155 ms
17,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); i++)

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<int> m(n);
  vector<vector<int>> b(n);

  rep(i, n) {
    cin >> a[i] >> m[i];
    b[i].resize(m[i]);
    rep(j, m[i]) cin >> b[i][j], b[i][j]--;
  }

  atcoder::mcf_graph<int, ll> G(n);
  const ll M = 1e9;

  rep(i, n) {
    for (auto j : b[i]) G.add_edge(j, i, 1, a[j] - a[i] + (i - j) * M);
  }
  rep(i, n - 1) G.add_edge(i, i + 1, n, M);

  cout << M * (n - 1) * k - G.flow(0, n - 1, k).second << "\n";
}
0