結果

問題 No.200 カードファイト!
ユーザー mayoko_mayoko_
提出日時 2015-07-29 07:41:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,999 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 76,836 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-24 21:28:12
合計ジャッジ時間 3,550 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 55;
int B[MAXN], D[MAXN];
int A, C, N;

bool done[2][MAXN];
int cnta = 0, cntc = 0;

int ok(int a) {
    for (int j = C-1; j >= 0; j--) {
        if (done[1][j]) continue;
        if (D[j] < B[a]) return j;
    }
    return -1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    cin >> A;
    for (int i = 0; i < A; i++) cin >> B[i];
    cin >> C;
    for (int i = 0; i < C; i++) cin >> D[i];
    int ans = 0;
    for (int t = 0; t < N; t++) {
        if (cnta >= A) {
            cnta = 0;
            memset(done[0], false, sizeof(done[0]));
        }
        if (cntc >= C) {
            cntc = 0;
            memset(done[1], false, sizeof(done[1]));
        }
        int a = -1, c = -1;
        for (int i = A-1; i >= 0; i--) {
            if (done[0][i]) continue;
            int tmp = ok(i);
            if (tmp == -1) break;
            a = i;
            c = tmp;
        }
        if (a != -1) {
            ans++;
            done[0][a] = true;
            done[1][c] = true;
        } else {
            for (int i = 0; i < A; i++) if (done[0][i]) {
                a = i;
                break;
            }
            for (int i = C-1; i >= 0; i--) if (done[1][i]) {
                c = i;
                break;
            }
            done[0][a] = true;
            done[1][c] = true;
        }
        cnta++;
        cntc++;
    }
    cout << ans << endl;
    return 0;
}
0