結果

問題 No.1678 Coin Trade (Multiple)
ユーザー googol_S0googol_S0
提出日時 2021-09-10 22:48:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 500 ms / 5,000 ms
コード長 689 bytes
コンパイル時間 4,567 ms
コンパイル使用メモリ 278,336 KB
実行使用メモリ 40,164 KB
最終ジャッジ日時 2023-09-02 20:00:47
合計ジャッジ時間 14,380 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 67 ms
18,480 KB
testcase_04 AC 226 ms
31,800 KB
testcase_05 AC 153 ms
38,440 KB
testcase_06 AC 128 ms
34,888 KB
testcase_07 AC 180 ms
21,700 KB
testcase_08 AC 138 ms
25,240 KB
testcase_09 AC 166 ms
38,372 KB
testcase_10 AC 50 ms
9,276 KB
testcase_11 AC 189 ms
29,768 KB
testcase_12 AC 47 ms
9,868 KB
testcase_13 AC 393 ms
36,504 KB
testcase_14 AC 108 ms
17,860 KB
testcase_15 AC 151 ms
29,092 KB
testcase_16 AC 79 ms
28,380 KB
testcase_17 AC 166 ms
39,232 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 1 ms
4,368 KB
testcase_22 AC 2 ms
4,372 KB
testcase_23 AC 2 ms
4,368 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 AC 2 ms
4,372 KB
testcase_26 AC 2 ms
4,372 KB
testcase_27 AC 1 ms
4,368 KB
testcase_28 AC 2 ms
4,372 KB
testcase_29 AC 2 ms
4,368 KB
testcase_30 AC 1 ms
4,368 KB
testcase_31 AC 2 ms
4,368 KB
testcase_32 AC 1 ms
4,372 KB
testcase_33 AC 2 ms
4,368 KB
testcase_34 AC 2 ms
4,368 KB
testcase_35 AC 2 ms
4,372 KB
testcase_36 AC 2 ms
4,368 KB
testcase_37 AC 2 ms
4,372 KB
testcase_38 AC 1 ms
4,368 KB
testcase_39 AC 2 ms
4,368 KB
testcase_40 AC 1 ms
4,368 KB
testcase_41 AC 2 ms
4,368 KB
testcase_42 AC 1 ms
4,368 KB
testcase_43 AC 1 ms
4,368 KB
testcase_44 AC 1 ms
4,368 KB
testcase_45 AC 2 ms
4,372 KB
testcase_46 AC 2 ms
4,368 KB
testcase_47 AC 2 ms
4,372 KB
testcase_48 AC 469 ms
40,060 KB
testcase_49 AC 467 ms
40,032 KB
testcase_50 AC 467 ms
40,056 KB
testcase_51 AC 460 ms
39,976 KB
testcase_52 AC 499 ms
39,964 KB
testcase_53 AC 470 ms
39,824 KB
testcase_54 AC 462 ms
40,164 KB
testcase_55 AC 470 ms
39,972 KB
testcase_56 AC 477 ms
40,144 KB
testcase_57 AC 500 ms
40,124 KB
testcase_58 AC 191 ms
36,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
int main(){
  ll INF=1000000000;
  int N,K;
  cin>>N>>K;
  mcf_graph<int,ll> G(N*3+2);
  int m;
  ll a;
  int x;
  G.add_edge(N*3,N*2,K,0);
  G.add_edge(N*3-1,N*3+1,K,INF);
  for(int i=0;i<N;i++){
    cin>>a>>m;
    if(i){
      G.add_edge(N*2+i-1,N*2+i,K,INF);
    }
    G.add_edge(N*2+i,i,K,a);
    G.add_edge(i,i+N,K,0);
    if(i+1==N){
      G.add_edge(i+N,N*3+1,K,INF-a);
    }else{
      G.add_edge(i+N,N*2+i+1,K,INF-a);
    }
    for(int j=0;j<m;j++){
      cin>>x;
      G.add_edge(x+N-1,i,1,INF*(i-x+1));
    }
  }
  cout<<INF*N*K-G.flow(N*3,N*3+1,K).second<<"\n";
}
0