結果

問題 No.110 しましまピラミッド
ユーザー YamaKasaYamaKasa
提出日時 2018-07-07 22:10:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,178 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 74,448 KB
実行使用メモリ 56,224 KB
最終ジャッジ日時 2023-09-19 03:56:26
合計ジャッジ時間 8,372 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,792 KB
testcase_01 WA -
testcase_02 AC 131 ms
55,832 KB
testcase_03 AC 130 ms
55,552 KB
testcase_04 AC 132 ms
55,552 KB
testcase_05 AC 130 ms
56,116 KB
testcase_06 AC 132 ms
55,808 KB
testcase_07 AC 133 ms
56,072 KB
testcase_08 WA -
testcase_09 AC 131 ms
55,728 KB
testcase_10 WA -
testcase_11 AC 135 ms
55,620 KB
testcase_12 WA -
testcase_13 AC 133 ms
55,908 KB
testcase_14 AC 132 ms
56,224 KB
testcase_15 AC 131 ms
55,556 KB
testcase_16 AC 129 ms
55,808 KB
testcase_17 WA -
testcase_18 AC 132 ms
55,720 KB
testcase_19 WA -
testcase_20 AC 134 ms
55,996 KB
testcase_21 AC 132 ms
55,716 KB
testcase_22 WA -
testcase_23 AC 133 ms
55,840 KB
testcase_24 AC 131 ms
55,744 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 137 ms
55,856 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 l = Nw - 2;
		int h = W[Nw - 1];
		int flag = 0;
		for(int i = Nb - 1; i >= 0; i--) {
			if(h > B[i] && flag == 0) {
				h = B[i];
				max1 ++;
				flag = 1;
				for(int j = l; j >= 0; j--) {
					if(h > W[j]) {
						max1++;
						h = W[j];
						l = l - 1;
						flag = 0;
						break;
					}
				}
			}
		}

		int max2 = 1;
		int l2 = Nb - 2;
		int h2 = B[Nb - 1];
		int flag2 = 1;
		for(int i = Nw - 1; i >= 0; i--) {
			if(h2 > W[i] && flag2 == 1) {
				h2 = W[i];
				max2 ++;
				flag = 0;
				for(int j = l2; j >= 0; j--) {
					if(h > B[j]) {
						max2++;
						h2 = B[j];
						l2 = l2 - 1;
						flag = 1;
						break;
					}
				}
			}
		}

		int ans = Math.max(max1, max2);
		System.out.println(ans);

	}
}
0