結果

問題 No.110 しましまピラミッド
ユーザー GrenacheGrenache
提出日時 2015-11-26 23:04:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 1,562 bytes
コンパイル時間 3,661 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 56,384 KB
最終ジャッジ日時 2023-08-30 03:50:20
合計ジャッジ時間 9,103 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,620 KB
testcase_01 AC 125 ms
56,324 KB
testcase_02 AC 122 ms
56,176 KB
testcase_03 AC 122 ms
56,192 KB
testcase_04 AC 123 ms
55,656 KB
testcase_05 AC 125 ms
55,616 KB
testcase_06 AC 124 ms
56,212 KB
testcase_07 AC 121 ms
55,840 KB
testcase_08 AC 123 ms
55,912 KB
testcase_09 AC 123 ms
56,092 KB
testcase_10 AC 121 ms
55,984 KB
testcase_11 AC 122 ms
56,212 KB
testcase_12 AC 122 ms
55,820 KB
testcase_13 AC 122 ms
55,976 KB
testcase_14 AC 122 ms
56,024 KB
testcase_15 AC 121 ms
56,072 KB
testcase_16 AC 123 ms
55,876 KB
testcase_17 AC 122 ms
56,384 KB
testcase_18 AC 119 ms
55,968 KB
testcase_19 AC 122 ms
56,068 KB
testcase_20 AC 123 ms
55,948 KB
testcase_21 AC 124 ms
55,952 KB
testcase_22 AC 124 ms
56,040 KB
testcase_23 AC 124 ms
56,328 KB
testcase_24 AC 124 ms
56,328 KB
testcase_25 AC 123 ms
55,640 KB
testcase_26 AC 124 ms
56,112 KB
testcase_27 AC 125 ms
56,380 KB
testcase_28 AC 124 ms
55,660 KB
testcase_29 AC 125 ms
55,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder110 {

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

        int nw = sc.nextInt();
        int[] w = new int[nw];
        for (int i = 0; i < nw; i++) {
        	w[i] = sc.nextInt();
        }
        Arrays.sort(w);

        int nb = sc.nextInt();
        int[] b = new int[nb];
        for (int i = 0; i < nb; i++) {
        	b[i] = sc.nextInt();
        }
        Arrays.sort(b);

        int prev = Integer.MAX_VALUE;
        int iw = nw - 1;
        int ib = nb - 1;
        int i;
        for (i = 0; iw >= 0 && ib >= 0; i++) {
        	if (i % 2 == 0) {
        		while (iw >= 0 && w[iw] >= prev) {
        			iw--;
        		}
        		if (iw >= 0) {
        			prev = w[iw];
        		}
        	} else {
        		while (ib >= 0 && b[ib] >= prev) {
        			ib--;
        		}
        		if (ib >= 0) {
        			prev = b[ib];
        		}
        	}

        }

        int ret = i;
        prev = Integer.MAX_VALUE;
        iw = nw - 1;
        ib = nb - 1;
        for (i = 0; iw >= 0 && ib >= 0; i++) {
        	if (i % 2 == 1) {
        		while (iw >= 0 && w[iw] >= prev) {
        			iw--;
        		}
        		if (iw >= 0) {
        			prev = w[iw];
        		}
        	} else {
        		while (ib >= 0 && b[ib] >= prev) {
        			ib--;
        		}
        		if (ib >= 0) {
        			prev = b[ib];
        		}
        	}
        }

        System.out.println(Math.max(ret, i) - 1);

        sc.close();
    }
}
0