結果

問題 No.110 しましまピラミッド
ユーザー tentententen
提出日時 2020-12-28 15:31:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 1,706 bytes
コンパイル時間 2,212 ms
コンパイル使用メモリ 77,720 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2024-04-14 08:33:27
合計ジャッジ時間 7,632 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
54,256 KB
testcase_01 AC 131 ms
53,984 KB
testcase_02 AC 134 ms
54,440 KB
testcase_03 AC 132 ms
54,272 KB
testcase_04 AC 131 ms
54,192 KB
testcase_05 AC 132 ms
53,960 KB
testcase_06 AC 135 ms
53,924 KB
testcase_07 AC 133 ms
54,108 KB
testcase_08 AC 133 ms
54,112 KB
testcase_09 AC 135 ms
54,108 KB
testcase_10 AC 135 ms
54,276 KB
testcase_11 AC 134 ms
54,232 KB
testcase_12 AC 134 ms
54,108 KB
testcase_13 AC 133 ms
54,168 KB
testcase_14 AC 132 ms
54,276 KB
testcase_15 AC 134 ms
54,320 KB
testcase_16 AC 135 ms
54,108 KB
testcase_17 AC 137 ms
54,272 KB
testcase_18 AC 136 ms
54,192 KB
testcase_19 AC 135 ms
53,912 KB
testcase_20 AC 132 ms
54,236 KB
testcase_21 AC 135 ms
54,152 KB
testcase_22 AC 133 ms
54,328 KB
testcase_23 AC 134 ms
54,300 KB
testcase_24 AC 133 ms
53,992 KB
testcase_25 AC 135 ms
54,184 KB
testcase_26 AC 136 ms
54,132 KB
testcase_27 AC 135 ms
54,256 KB
testcase_28 AC 132 ms
54,052 KB
testcase_29 AC 134 ms
54,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int wn = sc.nextInt();
        int[] wArr = new int[wn];
        for (int i = 0; i < wn; i++) {
            wArr[i] = sc.nextInt();
        }
        Arrays.sort(wArr);
        int bn = sc.nextInt();
        int[] bArr = new int[bn];
        for (int i = 0; i < bn; i++) {
            bArr[i] = sc.nextInt();
        }
        Arrays.sort(bArr);
        int wIdx = wn - 1;
        int bIdx = bn - 1;
        int wCount = 0;
        int wPrev = Integer.MAX_VALUE;
        while (true) {
            while (wIdx >= 0 && wPrev <= wArr[wIdx]) {
                wIdx--;
            }
            if (wIdx < 0) {
                break;
            }
            wCount++;
            wPrev = wArr[wIdx]; 
            while (bIdx >= 0 && wPrev <= bArr[bIdx]) {
                bIdx--;
            }
            if (bIdx < 0) {
                break;
            }
            wCount++;
            wPrev = bArr[bIdx]; 
        }
        wIdx = wn - 1;
        bIdx = bn - 1;
        int bCount = 0;
        int bPrev = Integer.MAX_VALUE;
        while (true) {
            while (bIdx >= 0 && bPrev <= bArr[bIdx]) {
                bIdx--;
            }
            if (bIdx < 0) {
                break;
            }
            bCount++;
            bPrev = bArr[bIdx];
            while (wIdx >= 0 && bPrev <= wArr[wIdx]) {
                wIdx--;
            }
            if (wIdx < 0) {
                break;
            }
            bCount++;
            bPrev = wArr[wIdx];
        }
        System.out.println(Math.max(wCount, bCount));
    }
}
0