結果

問題 No.930 数列圧縮
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-11-26 22:42:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 709 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 68,588 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-06 21:51:45
合計ジャッジ時間 5,558 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

constexpr int INF = 1 << 30;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }

    if(a[0] > a[n-1]) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    int i = 0;
    while(i < n-1) {
        int j = i+1;
        while(j < n-1 && a[i] < a[j] && a[0] < a[j]) {
            cout << a[j] << " ";
            a[j] = INF;
            ++j;
        }
        i = j;
    }
    i = 1;
    while(i < n-1) {
        if(a[i] < a[n-1]) cout << a[i] << " ";
        ++i;
    }
    cout << a[n-1] << endl;
}
0