結果

問題 No.930 数列圧縮
ユーザー 37zigen37zigen
提出日時 2019-11-22 23:29:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 728 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 2,015 ms
コンパイル使用メモリ 79,968 KB
実行使用メモリ 54,796 KB
最終ジャッジ日時 2024-04-19 12:40:03
合計ジャッジ時間 14,676 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
42,664 KB
testcase_01 AC 152 ms
42,812 KB
testcase_02 AC 154 ms
42,628 KB
testcase_03 AC 153 ms
42,724 KB
testcase_04 AC 169 ms
43,356 KB
testcase_05 AC 211 ms
45,336 KB
testcase_06 AC 159 ms
42,260 KB
testcase_07 AC 241 ms
47,580 KB
testcase_08 AC 529 ms
48,788 KB
testcase_09 AC 627 ms
52,272 KB
testcase_10 AC 610 ms
48,556 KB
testcase_11 AC 598 ms
50,156 KB
testcase_12 AC 664 ms
49,940 KB
testcase_13 AC 353 ms
47,792 KB
testcase_14 AC 448 ms
47,852 KB
testcase_15 AC 629 ms
54,292 KB
testcase_16 AC 605 ms
52,668 KB
testcase_17 AC 728 ms
53,404 KB
testcase_18 AC 620 ms
53,612 KB
testcase_19 AC 704 ms
53,832 KB
testcase_20 AC 703 ms
54,796 KB
testcase_21 AC 673 ms
53,972 KB
testcase_22 AC 136 ms
42,536 KB
testcase_23 AC 614 ms
53,172 KB
testcase_24 AC 126 ms
41,956 KB
testcase_25 AC 110 ms
41,328 KB
testcase_26 AC 138 ms
42,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
import java.io.*;

class Main
{
    public static void main(String[] args)
    {
        new Main().run();
    }
    
    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
        }
        if (a[0] > a[N - 1]) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
        PrintWriter pw = new PrintWriter(System.out);
        int[] ans = new int[N];
        int p = 0;
        for (int i = 1; i < a[N - 1]; ++i) {
            if (i != a[0]) {
                ans[p++] = i;
            }
        }
        for (int i = N; i >= a[N - 1]; --i) {
            ans[p++] = i;
        }
        for (int i = 0; i < p; ++i) {
            pw.print(ans[i] + (i == p - 1 ? "\n" : " "));
        }
        pw.close();
    }
    
}
0