結果

問題 No.110 しましまピラミッド
ユーザー ikd
提出日時 2016-07-23 19:37:18
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,019 bytes
コンパイル時間 1,042 ms
コンパイル使用メモリ 66,612 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 11:21:39
合計ジャッジ時間 1,897 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int cal(vector<int> a, vector<int> b){
    int cnt=0, pre=100, i=0, j=0;
    while(1){
        while(1){
            if(i>=a.size()) return cnt;
            if(a[i]<pre){
                pre=a[i++];
                cnt++;
                break;
            }
            i++;
        }
        while(1){
            if(j>=b.size()) return cnt;
            if(b[j]<pre){
                pre=b[j++];
                cnt++;
                break;
            }
            j++;
        }
    }

}


int main(){
    int N, M;
    vector<int> W, B;
    cin>> N;
    for(int i=0; i<N; i++){
        int x;
        cin>> x;
        W.push_back(x);
    }
    cin>> M;
    for(int i=0; i<M; i++){
        int x;
        cin>> x;
        B.push_back(x);
    }

    sort(W.begin(), W.end());
    sort(B.begin(), B.end());
    reverse(W.begin(), W.end());
    reverse(B.begin(), B.end());

    cout<< max(cal(W, B), cal(B, W))<< endl;

    return 0;
}
0