結果

問題 No.110 しましまピラミッド
ユーザー imulanimulan
提出日時 2016-02-05 19:48:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,535 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 148,976 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:51:57
合計ジャッジ時間 2,450 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int nw,nb;
  cin >>nw;
  std::vector<int> w(nw);
  rep(i,nw) cin >>w[i];
  cin >>nb;
  std::vector<int> b(nb);
  rep(i,nb) cin >>b[i];

  sort(w.begin(),w.end());
  sort(b.begin(),b.end());

  int p=0,q=0;
  //白を一番下に積む時
  bool white=true;
  int ww=nw-1;
  int bb=nb-1;
  int now=100;
  while(1){
    if(white){
      while(now<=w[ww]){
        --ww;
        if(ww==-1) break;
      }

      if(ww==-1) break;
      else{
        ++p;
        now=w[ww];
        white=false;
      }
    }
    else{
      while(now<=b[bb]){
        --bb;
        if(bb==-1) break;
      }

      if(bb==-1) break;
      else{
        ++p;
        now=b[bb];
        white=true;
      }
    }
  }


  //黒を一番下に積む時
  white=false;
  ww=nw-1;
  bb=nb-1;
  now=100;
  while(1){
    if(white){
      while(now<=w[ww]){
        --ww;
        if(ww==-1) break;
      }

      if(ww==-1) break;
      else{
        ++q;
        now=w[ww];
        white=false;
      }
    }
    else{
      while(now<=b[bb]){
        --bb;
        if(bb==-1) break;
      }

      if(bb==-1) break;
      else{
        ++q;
        now=b[bb];
        white=true;
      }
    }
  }

  std::cout << max(p,q) << std::endl;
  return 0;
}
0