結果

問題 No.930 数列圧縮
ユーザー htensaihtensai
提出日時 2020-05-15 09:19:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 590 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 3,519 ms
コンパイル使用メモリ 75,396 KB
実行使用メモリ 62,500 KB
最終ジャッジ日時 2023-10-17 18:15:17
合計ジャッジ時間 16,376 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,564 KB
testcase_01 AC 142 ms
57,708 KB
testcase_02 AC 140 ms
57,192 KB
testcase_03 AC 145 ms
57,448 KB
testcase_04 AC 180 ms
57,788 KB
testcase_05 AC 190 ms
57,768 KB
testcase_06 AC 190 ms
57,960 KB
testcase_07 AC 215 ms
60,424 KB
testcase_08 AC 513 ms
62,052 KB
testcase_09 AC 551 ms
62,100 KB
testcase_10 AC 511 ms
61,864 KB
testcase_11 AC 510 ms
62,008 KB
testcase_12 AC 536 ms
62,072 KB
testcase_13 AC 422 ms
61,996 KB
testcase_14 AC 481 ms
62,000 KB
testcase_15 AC 578 ms
62,100 KB
testcase_16 AC 567 ms
62,500 KB
testcase_17 AC 565 ms
62,076 KB
testcase_18 AC 555 ms
62,060 KB
testcase_19 AC 590 ms
62,260 KB
testcase_20 AC 587 ms
62,072 KB
testcase_21 AC 556 ms
62,000 KB
testcase_22 AC 133 ms
57,480 KB
testcase_23 AC 567 ms
62,184 KB
testcase_24 AC 131 ms
57,488 KB
testcase_25 AC 132 ms
57,532 KB
testcase_26 AC 132 ms
57,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        StringBuilder sb = new StringBuilder();
        if (arr[0] < arr[n - 1]) {
            sb.append("Yes\n");
            for (int i = 1; i < n - 1; i++) {
                if (arr[0] < arr[i]) {
                    sb.append(arr[i]).append(" ");
                    arr[i] = Integer.MAX_VALUE;
                }
            }
            for (int i = n - 2; i >= 1; i--) {
                 if (arr[i] < arr[n - 1]) {
                    sb.append(arr[i]).append(" ");
                }
            }
            sb.append(arr[0]);
        } else {
            sb.append("No");
        }
        System.out.println(sb);
    }
}
0