結果

問題 No.110 しましまピラミッド
ユーザー krotonkroton
提出日時 2014-12-23 19:08:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 811 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 147,040 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:43:38
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
int w_size, b_size;
int W[22], B[22];
 
int solve(int h, int last, int turn, int wk, int bk){
	if(turn == 0){
		if(wk >= w_size)return h;
		if(W[wk] < last){
			return solve(h + 1, W[wk], 1, wk + 1, bk);
		} else {
			return solve(h, last, 0, wk + 1, bk);
		}
	} else {
		if(bk >= b_size)return h;
		if(B[bk] < last){
			return solve(h + 1, B[bk], 0, wk, bk + 1);
		} else {
			return solve(h, last, 1, wk, bk + 1);
		}
	}
}
 
int main(){
	cin >> w_size;
	for(int i=0;i<w_size;i++)cin >> W[i];
 
	cin >> b_size;
	for(int i=0;i<b_size;i++)cin >> B[i];
 
	sort(W, W + w_size, greater<int>());
	sort(B, B + b_size, greater<int>());
 
	int res = 0;
	res = max(res, solve(0, 100, 0, 0, 0));
	res = max(res, solve(0, 100, 1, 0, 0));
 
	cout << res << endl;
	return 0;
}
0