結果

問題 No.110 しましまピラミッド
ユーザー kpinkcatkpinkcat
提出日時 2023-10-23 09:48:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,732 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 206,868 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-23 09:48:24
合計ジャッジ時間 3,602 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    int nw, nb, pw = 0, pb = 0, answ = 0, ansb = 0;
    cin >> nw;
    vector<int> w(nw);
    for (int i = 0; i < nw; i++) cin >> w[i];
    cin >> nb;
    vector<int> b(nb);
    for (int i = 0; i < nb; i++) cin >> b[i];
    sort(w.begin(), w.end(), greater());
    sort(b.begin(), b.end(), greater());
    
    // black first -> white を探索
    if (nb) ansb++;
    for (int i = pw; i < nw; i++){
        bool found = false;
        if (w[i] < b[pb]){
            ansb++;
            pw = i+1;
            pb++;
            if (pb == nb) break;
            for (int j = pb; j < nb; j ++){
                if (w[i] > b[j]){
                    ansb++;
                    pb = j;
                    found = true;
                    break;
                }
            }
            if (pb == nb) break;
        }
        if (pb == nb) break;
        if (!found) break;
    }
    pb = 0;
    pw = 0;
    if (nw) answ++;
    for (int i = pb; i < nb; i++){
        bool found = false;
        if (b[i] < w[pw]){
            answ++;
            pb = i;
            pw++;
            if (pw == nw) break;
            for (int j = pw; j < nw; j ++){
                if (b[i] > w[j]){
                    answ++;
                    pw = j;
                    found = true;
                    break;
                }
                if (j = nw-1) pw = nw;
            }
        }
        if (pw == nw) break;
        if (!found) break;
    }
    cout << max(answ, ansb) << endl;
}
0