結果
問題 | No.1678 Coin Trade (Multiple) |
ユーザー |
![]() |
提出日時 | 2021-09-10 23:21:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 254 ms / 5,000 ms |
コード長 | 711 bytes |
コンパイル時間 | 3,007 ms |
コンパイル使用メモリ | 217,284 KB |
最終ジャッジ日時 | 2025-01-24 12:20:18 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 56 |
ソースコード
#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; }