結果

問題 No.1541 ゅゅさんのテスト勉強
ユーザー umezoumezo
提出日時 2021-06-06 20:06:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 882 bytes
コンパイル時間 2,615 ms
コンパイル使用メモリ 212,060 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-15 09:27:17
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 RE -
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include <bits/stdc++.h>
#include <atcoder/maxflow>
using namespace std;
using namespace atcoder;

const ll INF=1e18+7;

int main(){
  int n;
  ll m;
  cin>>n>>m;
  
  mf_graph<ll> graph(500);
  
  ll sum=0;
  for(int i=1;i<=n;i++){
    int k;
    ll c;
    cin>>k>>c;
    if(m-c>=0){
      sum+=m-c;
      graph.add_edge(0,i,m-c);
      graph.add_edge(i,n+1,0);
    }
    else{
      graph.add_edge(0,i,0);
      graph.add_edge(i,n+1,c-m);
    }
    if(k==0) continue;
    vector<int> A(k);
    vector<ll> B(k);
    rep(j,k) cin>>A[j];
    rep(j,k) cin>>B[j];
    rep(j,k){
      int t=20*i+A[j]+30;
      sum+=B[j];
      graph.add_edge(0,t,B[j]);
      graph.add_edge(t,i,INF);
      graph.add_edge(t,A[j],INF);
    }
  }
  
  cout<<sum-graph.flow(0,n+1)<<endl;
  
  return 0;
}
0