結果
| 問題 |
No.1678 Coin Trade (Multiple)
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-09-10 22:16:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 309 ms / 5,000 ms |
| コード長 | 749 bytes |
| コンパイル時間 | 5,249 ms |
| コンパイル使用メモリ | 266,112 KB |
| 最終ジャッジ日時 | 2025-01-24 11:20:18 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf (long long)2000000000
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];
B[i].resize(M[i]);
rep(j,M[i]){
cin>>B[i][j];
B[i][j]--;
}
}
mcf_graph<long long,long long> G(N);
rep(i,N-1){
G.add_edge(i,i+1,100,Inf);
}
rep(i,N){
rep(j,B[i].size()){
int x = B[i][j];
int y = i;
G.add_edge(x,y,1,Inf*(y-x) - (-A[x]+A[y]));
}
}
long long ans = G.flow(0,N-1,K).second;
rep(i,K){
ans -= Inf*(N-1);
}
ans *= -1;
cout<<ans<<endl;
return 0;
}
沙耶花