結果

問題 No.110 しましまピラミッド
ユーザー YamaKasaYamaKasa
提出日時 2018-07-07 20:47:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,046 bytes
コンパイル時間 3,104 ms
コンパイル使用メモリ 75,032 KB
実行使用メモリ 58,336 KB
最終ジャッジ日時 2023-09-18 14:49:50
合計ジャッジ時間 7,141 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 125 ms
55,684 KB
testcase_03 AC 128 ms
55,704 KB
testcase_04 AC 126 ms
55,936 KB
testcase_05 AC 127 ms
55,936 KB
testcase_06 AC 126 ms
55,860 KB
testcase_07 AC 127 ms
55,984 KB
testcase_08 WA -
testcase_09 AC 128 ms
55,888 KB
testcase_10 WA -
testcase_11 AC 126 ms
55,644 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 127 ms
55,988 KB
testcase_15 WA -
testcase_16 AC 127 ms
56,008 KB
testcase_17 WA -
testcase_18 AC 126 ms
55,912 KB
testcase_19 WA -
testcase_20 AC 128 ms
53,848 KB
testcase_21 AC 127 ms
55,632 KB
testcase_22 WA -
testcase_23 AC 128 ms
55,572 KB
testcase_24 AC 127 ms
55,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 129 ms
55,844 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int Nw = scan.nextInt();
		int []W = new int[Nw];
		for(int i = 0; i < Nw; i++) {
			W[i] = scan.nextInt();
		}
		int Nb = scan.nextInt();
		int []B = new int[Nb];
		for(int i = 0; i < Nb; i++) {
			B[i] = scan.nextInt();
		}
		scan.close();
		Arrays.sort(W);
		Arrays.sort(B);

		int max1 = 1;

		int h = W[Nw - 1];
		for(int i = Nb - 1; i >= 0; i--) {
			if(h > B[i]) {
				h = B[i];
				max1 ++;
				for(int j = Nw - 1; j >= 0; j--) {
					if(h > W[j]) {
						max1++;
						h = W[j];
						j = j - 1;
						break;
					}
				}
			}
		}

		int max2 = 1;
		int l2 = Nb - 2;
		int h2 = B[Nb - 1];

		for(int i = Nw - 1; i >= 0; i--) {
			if(h2 > W[i]) {
				h2 = W[i];
				max2 ++;
				for(int j = l2; j >= 0; j--) {
					if(h > B[j]) {
						max2++;
						h2 = B[j];
						l2 = l2 - 1;
						break;
					}
				}
			}
		}
		int ans = Math.max(max1, max2);
		System.out.println(ans);

	}
}
0