結果

問題 No.110 しましまピラミッド
ユーザー Bantako
提出日時 2018-05-27 10:42:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 749 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 172,248 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 11:40:58
合計ジャッジ時間 2,701 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
int Nw,Nb;
int func(bool flag, vector<int> W, vector<int> B){
    int wi = 0,bi = 0,cnt = 0,num = 0;
    while(wi < Nw && bi < Nb){
        if(flag){
            while(num >= W[wi])wi++;
            num = W[wi];
        }else{
            while(num >= B[bi])bi++;
            num = B[bi];
        }
        cnt++;
        flag = !flag;
    }
    return cnt;
}
main(){
    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());
    sort(B.begin(), B.end());
    cout << max(func(1,W,B), func(0,W,B)) - 1 << endl;
}
0