結果

問題 No.110 しましまピラミッド
ユーザー togatogatogatoga
提出日時 2015-08-03 22:58:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,852 bytes
コンパイル時間 946 ms
コンパイル使用メモリ 99,000 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 03:49:30
合計ジャッジ時間 2,162 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp       make_pair
#define mt       make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N,M;
vector<int> W,B;

int main(){
  cin >> N;
  W.resize(N);
  for (int i = 0; i < N; i++){
    cin >> W[i];
  }
  cin >> M;
  B.resize(M);
  for (int i = 0; i < M; i++){
    cin >> B[i];
  }
  sort(W.rbegin(), W.rend());
  sort(B.rbegin(), B.rend());
  int res = 0;
  int cnt = 0;
  for (int cnt = 0; cnt < 2; cnt++){
    int width = 114514;
    stack<int> st;
    st.push(width);
    int b,w;
    b = w = 0;
    int color = cnt;
    while (true){//black
      if (color == 0){
	if (w < W.size()){
	  bool ok = false;
	  for (int i = w; i < W.size(); i++){
	    if (st.top() > W[i]){
	      w = i;
	      st.push(W[i]);
	      w++;
	      ok = true;
	      break;
	    }
	  }
	  if (!ok)break;
	}else{
	  break;
	}
      }else{
	if (b < B.size()){
	  bool ok = false;
	  for (int i = b; i < B.size(); i++){
	    if (st.top() > B[i]){
	      b = i;
	      st.push(B[i]);
	      b++;
	      ok = true;
	      break;
	    }
	  }
	  if (!ok)break;
	}else{
	  break;
	}
      }
      color = !color;
    }

    res = max(res, (int)st.size() - 1);
    while(!st.empty()){st.pop();}
  }
  cout << res << endl;
  return 0;
}
0