結果

問題 No.930 数列圧縮
ユーザー htensaihtensai
提出日時 2020-01-27 14:29:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 848 bytes
コンパイル時間 3,956 ms
コンパイル使用メモリ 72,256 KB
実行使用メモリ 64,380 KB
最終ジャッジ日時 2023-10-12 12:56:26
合計ジャッジ時間 17,750 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
54,364 KB
testcase_01 WA -
testcase_02 AC 131 ms
55,912 KB
testcase_03 AC 144 ms
55,968 KB
testcase_04 WA -
testcase_05 AC 190 ms
56,080 KB
testcase_06 AC 185 ms
56,044 KB
testcase_07 WA -
testcase_08 AC 484 ms
60,352 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 476 ms
60,844 KB
testcase_12 WA -
testcase_13 AC 402 ms
60,376 KB
testcase_14 AC 456 ms
60,384 KB
testcase_15 AC 544 ms
60,672 KB
testcase_16 AC 543 ms
60,212 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 576 ms
60,764 KB
testcase_20 WA -
testcase_21 AC 559 ms
60,796 KB
testcase_22 AC 122 ms
56,200 KB
testcase_23 AC 549 ms
60,244 KB
testcase_24 AC 121 ms
54,072 KB
testcase_25 AC 120 ms
56,108 KB
testcase_26 AC 121 ms
55,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        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();
        }
        if (arr[0] >= arr[n - 1]) {
            System.out.println("No");
            return;
        }
        StringBuilder sb = new StringBuilder("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[n - 1] > arr[i]) {
                sb.append(arr[i]).append(" ");
            }
        }
        sb.append(arr[n - 1]);
        System.out.println(sb);
   }
}
0