結果
| 問題 |
No.1678 Coin Trade (Multiple)
|
| コンテスト | |
| ユーザー |
👑 tatyam
|
| 提出日時 | 2021-09-10 23:03:30 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 176 ms / 5,000 ms |
| コード長 | 647 bytes |
| コンパイル時間 | 3,989 ms |
| コンパイル使用メモリ | 270,000 KB |
| 実行使用メモリ | 15,344 KB |
| 最終ジャッジ日時 | 2024-06-12 03:16:27 |
| 合計ジャッジ時間 | 8,047 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/mincostflow>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N, K;
cin >> N >> K;
atcoder::mcf_graph<ll, ll> g(N);
for(ll i = 0; i < N - 1; i++) g.add_edge(i, i + 1, K, 1LL << 30);
vector<ll> A(N);
for(ll i = 0; i < N; i++){
ll M;
cin >> A[i] >> M;
while(M--){
ll B;
cin >> B;
B--;
if(A[B] < A[i]) g.add_edge(B, i, 1, ((i - B) << 30) - (A[i] - A[B]));
}
}
cout << ((K * (N - 1)) << 30) - g.flow(0, N - 1, K).second << endl;
}
tatyam