結果

問題 No.110 しましまピラミッド
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-02-28 03:12:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 937 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 62,136 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 03:53:06
合計ジャッジ時間 1,935 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>

using namespace std;

#define NwMAX 10
#define NbMAX 10
#define BLACK 0
#define WHITE 1

int main(){

	int Nw,Nb;
	int W[NwMAX],B[NbMAX];
	int ans=0;
	int h=0,wb=0;
	int i,j;
	int turn;

	cin>>Nw;
	for(int i=0;i<Nw;i++) cin>>W[i];
	cin>>Nb;
	for(int i=0;i<Nb;i++) cin>>B[i];

	sort(W,W+Nw);
	sort(B,B+Nb);

	wb=W[Nw-1];
	h=1;
	i=Nw-2,j=Nb-1;
	turn=BLACK;
	while(1){
		if(turn==BLACK){
			if(j==-1) break;
			if(B[j]<wb){
				wb=B[j];
				turn=WHITE;
				h++;
			}
			j--;
		}
		else{
			if(i==-1) break;
			if(W[i]<wb){
				wb=W[i];
				turn=BLACK;
				h++;
			}
			i--;
		}
	}

	ans=h;

	wb=B[Nb-1];
	h=1;
	i=Nw-1,j=Nb-2;
	turn=WHITE;
	while(1){
		if(turn==BLACK){
			if(j==-1) break;
			if(B[j]<wb){
				wb=B[j];
				turn=WHITE;
				h++;
			}
			j--;
		}
		else{
			if(i==-1) break;
			if(W[i]<wb){
				wb=W[i];
				turn=BLACK;
				h++;
			}
			i--;
		}
	}

	if(ans<h) ans=h;
	cout<<ans<<endl;
}
0