結果

問題 No.110 しましまピラミッド
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-02-28 03:11:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 957 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 60,616 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 18:43:10
合計ジャッジ時間 2,098 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);

	cout<<W[0]<<endl;

	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