結果

問題 No.930 数列圧縮
ユーザー cotton_fn_cotton_fn_
提出日時 2019-12-11 14:47:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 1,232 ms
コンパイル使用メモリ 101,804 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 13:04:46
合計ジャッジ時間 4,630 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 24 ms
4,384 KB
testcase_09 AC 28 ms
4,380 KB
testcase_10 AC 22 ms
4,384 KB
testcase_11 AC 25 ms
4,384 KB
testcase_12 AC 29 ms
4,380 KB
testcase_13 AC 15 ms
4,384 KB
testcase_14 AC 16 ms
4,380 KB
testcase_15 AC 34 ms
4,384 KB
testcase_16 AC 34 ms
4,380 KB
testcase_17 AC 34 ms
4,380 KB
testcase_18 AC 34 ms
4,384 KB
testcase_19 AC 34 ms
4,384 KB
testcase_20 AC 34 ms
4,384 KB
testcase_21 AC 34 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 32 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
int n;
vector<int> a;
int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    if (a[0] > a[n - 1]) {
        cout << "No\n";
        return 0;
    }
    vector<int> res;
    for (int l = 1, r = 1; r < n; ) {
        while (a[r] <= a[0]) ++r;
        for (int i = r - 1; i >= l; --i) {
            res.push_back(a[i]);
        }
        res.push_back(a[r]);
        r++;
        l = r;
    }
    assert(res.size() == n - 1);
    cout << "Yes\n";
    for (int x : res) cout << x << ' ';
    cout << endl;
    return 0;
}
0