結果

問題 No.110 しましまピラミッド
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-21 01:43:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 1,192 bytes
コンパイル時間 3,704 ms
コンパイル使用メモリ 74,504 KB
実行使用メモリ 56,436 KB
最終ジャッジ日時 2023-08-30 04:04:33
合計ジャッジ時間 8,763 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
56,080 KB
testcase_01 AC 125 ms
56,436 KB
testcase_02 AC 127 ms
55,824 KB
testcase_03 AC 126 ms
56,232 KB
testcase_04 AC 125 ms
56,076 KB
testcase_05 AC 127 ms
55,772 KB
testcase_06 AC 123 ms
55,776 KB
testcase_07 AC 126 ms
55,980 KB
testcase_08 AC 126 ms
55,720 KB
testcase_09 AC 127 ms
55,908 KB
testcase_10 AC 126 ms
55,792 KB
testcase_11 AC 129 ms
56,020 KB
testcase_12 AC 125 ms
55,944 KB
testcase_13 AC 126 ms
55,812 KB
testcase_14 AC 126 ms
55,616 KB
testcase_15 AC 125 ms
56,116 KB
testcase_16 AC 125 ms
55,896 KB
testcase_17 AC 125 ms
55,996 KB
testcase_18 AC 126 ms
55,844 KB
testcase_19 AC 128 ms
55,760 KB
testcase_20 AC 125 ms
55,840 KB
testcase_21 AC 127 ms
56,128 KB
testcase_22 AC 126 ms
55,580 KB
testcase_23 AC 128 ms
55,792 KB
testcase_24 AC 128 ms
55,576 KB
testcase_25 AC 126 ms
55,824 KB
testcase_26 AC 127 ms
55,836 KB
testcase_27 AC 127 ms
55,924 KB
testcase_28 AC 124 ms
55,844 KB
testcase_29 AC 126 ms
56,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

public class No110{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N_w = sc.nextInt();
		int[] W = new int[N_w];
		for(int i = 0; i < N_w; i++){
			W[i] = sc.nextInt();
		}
		int N_b = sc.nextInt();
		int[] B = new int[N_b];
		for(int i = 0; i < N_b; i++){
			B[i] = sc.nextInt();
		}

		Arrays.sort(W);
		Arrays.sort(B);
		int height_w_start = stack(W, B);
		int height_b_start = stack(B, W);
		System.out.println(Math.max(height_w_start, height_b_start));
	}

	private static int stack(int[] block_0, int[] block_1){
		int height = 0;
		int width = 30;
		int max;
		boolean put_flg;
		while(true){
			max = 0;
			put_flg = false;
			for(int i = 0; i < block_0.length; i++){
				if(block_0[i] > max && block_0[i] < width){
					max = block_0[i];
					put_flg = true;
				}
			}
			if(put_flg)	height++;
			else break;
			width = max;
			
			max = 0;
			put_flg = false;
			for(int i = 0; i < block_1.length; i++){
				if(block_1[i] > max && block_1[i] < width){
					max = block_1[i];
					put_flg = true;
				}
			}
			if(put_flg) height++;
			else break;
			width = max;
		}
		return height;
	}
}
0