結果

問題 No.930 数列圧縮
コンテスト
ユーザー WutongDeath
提出日時 2026-11-23 04:34:34
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 13 ms / 2,000 ms
+ 822µs
コード長 612 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,086 ms
コンパイル使用メモリ 160,112 KB
実行使用メモリ 9,908 KB
最終ジャッジ日時 2026-11-23 04:34:40
合計ジャッジ時間 4,602 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdio>

using namespace std;

const int N = 100010;

int n, a[N], cnt, ans[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    if (a[1] > a[n]) {
        puts("No");
        return 0;
    }
    
    int l = 2;
    for (int i = 2; i <= n; ++i) {
        if (a[i] > a[1]) {
            for (int j = i - 1; j >= l; --j) ans[++cnt] = a[j];
            ans[++cnt] = a[i];
            l = i + 1;
        }
    }
    
    puts("Yes");
    for (int i = 1; i <= cnt; ++i) {
        printf("%d%c", ans[i], " \n"[i == cnt]);
    }

    return 0;
}
0