結果

問題 No.1678 Coin Trade (Multiple)
ユーザー TKTYITKTYI
提出日時 2021-09-11 23:10:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 1,063 bytes
コンパイル時間 4,731 ms
コンパイル使用メモリ 247,412 KB
実行使用メモリ 22,024 KB
最終ジャッジ日時 2023-09-05 12:50:20
合計ジャッジ時間 11,541 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 60 ms
13,896 KB
testcase_04 AC 155 ms
18,432 KB
testcase_05 AC 104 ms
20,712 KB
testcase_06 AC 92 ms
20,192 KB
testcase_07 AC 136 ms
15,212 KB
testcase_08 AC 106 ms
16,012 KB
testcase_09 AC 110 ms
22,024 KB
testcase_10 AC 48 ms
9,928 KB
testcase_11 AC 125 ms
17,788 KB
testcase_12 AC 46 ms
10,752 KB
testcase_13 AC 207 ms
20,068 KB
testcase_14 AC 91 ms
13,624 KB
testcase_15 AC 107 ms
17,416 KB
testcase_16 AC 67 ms
18,880 KB
testcase_17 AC 112 ms
21,128 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 258 ms
21,544 KB
testcase_49 AC 255 ms
21,456 KB
testcase_50 AC 256 ms
21,372 KB
testcase_51 AC 254 ms
21,916 KB
testcase_52 AC 252 ms
21,808 KB
testcase_53 AC 256 ms
21,676 KB
testcase_54 AC 257 ms
21,520 KB
testcase_55 AC 248 ms
21,904 KB
testcase_56 AC 255 ms
21,636 KB
testcase_57 AC 247 ms
21,312 KB
testcase_58 AC 155 ms
18,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef long double ld;
#define FOR(i,l,r) for(ll i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,l,r) for(ll i=r-1;i>=l;i--)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
#define BS(A,x) binary_search(ALL(A),x)
#define LB(A,x) (ll)(lower_bound(ALL(A),x)-A.begin())
#define UB(A,x) (ll)(upper_bound(ALL(A),x)-A.begin())
#define COU(A,x) UB(A,x)-LB(A,x)
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
using mint=modint1000000007;
signed main(){
  ll N,K;cin>>N>>K;vector<ll>A(N),M(N);vector<vector<ll>>B(N,vector<ll>());
  REP(i,N){cin>>A[i]>>M[i];REP(j,M[i]){ll b;cin>>b;B[i].push_back(b-1);}}
  mcf_graph<ll,ll>graph(N);REP(i,N-1)graph.add_edge(i,i+1,K,1000000000);
  REP(i,N)REP(j,M[i])graph.add_edge(B[i][j],i,1,A[B[i][j]]-A[i]+1000000000*(i-B[i][j]));
  cout<<1000000000*(N-1)*K-graph.flow(0,N-1,K).S<<endl;
  return 0;
}
0