結果

問題 No.110 しましまピラミッド
ユーザー itezpaceitezpace
提出日時 2016-07-30 08:42:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,200 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 67,212 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:55:16
合計ジャッジ時間 1,851 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int nw,w,nb,b;
  cin>>nw;
  vector<int> vw,vb;
  for(int i=0; i<nw; ++i){
    cin>>w;
    vw.push_back(w);
  }
  cin>>nb;
  for(int i=0; i<nb; ++i){
    cin>>b;
    vb.push_back(b);
  }
  sort(vw.begin(),vw.end(),greater<int>());
  sort(vb.begin(),vb.end(),greater<int>());
  int x;
  x=0;
  int wv,bv;
  wv=vw[0];
  x++;
  int f;
  f=1;
  while(1){
    if(f==0) break;
    f=0;
    for(int i=0; i<vb.size(); ++i){
      if(vb[i]<wv){
        bv=vb[i];
        x++;
        f=1;
        break;
      }
    }
    if(f==0) break;
    f=0;
    for(int i=0; i<vw.size(); ++i){
      if(vw[i]<bv){
        wv=vw[i];
        x++;
        f=1;
        break;
      }
    }
  }
  int y;
  y=0;
  bv=vb[0];
  y++;
  f=1;
  while(1){
    if(f==0) break;
    f=0;
    for(int i=0; i<vw.size(); ++i){
      if(vw[i]<bv){
        wv=vw[i];
        y++;
        f=1;
        break;
      }
    }
    if(f==0) break;
    f=0;
    for(int i=0; i<vb.size(); ++i){
      if(vb[i]<wv){
        bv=vb[i];
        y++;
        f=1;
        break;
      }
    }
  }
  int z;
  z=x;
  if(x<y) z=y;
  cout<<z<<endl;
  return 0;
}
0