結果

問題 No.200 カードファイト!
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-01-08 22:05:45
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,234 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 94,324 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 22:40:25
合計ジャッジ時間 2,513 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000009

#define PMAX_A 50
#define PMAX_B 50

#define NN (PMAX_A+PMAX_B+2)

int vv[NN][NN];
int flag[NN];

int flow(int s, int e, int f){
  if(s == e)return f;

  flag[s] = 1;

  for(int i = 0; i < NN; i++){
    if(vv[s][i] > 0 && flag[i] == 0){
      int d = flow(i, e, min(f, vv[s][i]));
      if(d > 0){
        vv[s][i] -= d;
        vv[i][s] += d;
        return d;
      }
    }
  }
  return 0;
}

void ae(int from, int to, int cost){
  vv[from][to] = cost;
  vv[to][from] = 0;
}

int pmatch(int pa[PMAX_A][PMAX_B]){
  memset(vv,-1,sizeof(vv));

  for(int i = 1; i <= PMAX_A; i++){
    ae(0,i,1);
  }

  for(int i = 0; i < PMAX_A; i++){
    for(int j = 0; j < PMAX_B; j++){
      if(pa[i][j] == 1){
        ae(i+1,j+PMAX_A+1,1);
      }
    }
  }

  for(int i = PMAX_A+1; i <= PMAX_A+PMAX_B; i++){
    ae(i,PMAX_A+PMAX_B+1,1);
  }

  int ans = 0;

  for(;;){
    memset(flag,0,sizeof(flag));
    int f = flow(0, PMAX_A+PMAX_B+1, 1000000000);
    if(f == 0)break;
    ans += f;
  }

  return ans;
}

int main(){
  int n;
  cin>>n;
  int a;
  cin>>a;
  vector<int> b;
  rep(i,0,a){
    int b1;
    cin>>b1;
    b.pb(b1);
  }
  int c;
  cin>>c;
  vector<int> d;
  rep(i,0,c){
    int d1;
    cin>>d1;
    d.pb(d1);
  }
  sort(all(b),greater<int>());
  sort(all(d));
  vector<int> A;
  vector<int> C;
  rep(i,0,100){
    rep(j,0,b.sz)A.pb(b[j]);
    rep(j,0,d.sz)C.pb(d[j]);
  }
  
  int pa[PMAX_A][PMAX_B];

  memset(pa,0,sizeof(pa));

  rep(i,0,n){
    rep(j,0,c){
      if(A[i]>C[i/c*c+j]){
        pa[i][i/c*c+j]=1;
      }
    }
  }

  cout << pmatch(pa) << endl;

  return 0;
}

/*
2部マッチングです。
*/
0