結果

問題 No.930 数列圧縮
コンテスト
ユーザー zelda_master
提出日時 2026-11-26 21:23:13
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 13 ms / 2,000 ms
+ 906µs
コード長 700 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 392 ms
コンパイル使用メモリ 79,116 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-11-26 21:23:18
合計ジャッジ時間 3,732 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_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() {
    // freopen("compress.in", "r", stdin);
    // freopen("compress.out", "w", stdout);

    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