結果

問題 No.930 数列圧縮
ユーザー CleyLCleyL
提出日時 2022-09-22 11:03:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 613 ms
コンパイル使用メモリ 75,292 KB
実行使用メモリ 4,780 KB
最終ジャッジ日時 2023-08-23 20:28:32
合計ジャッジ時間 3,146 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 25 ms
4,380 KB
testcase_09 AC 29 ms
4,532 KB
testcase_10 AC 23 ms
4,380 KB
testcase_11 AC 26 ms
4,380 KB
testcase_12 AC 29 ms
4,380 KB
testcase_13 AC 14 ms
4,376 KB
testcase_14 AC 17 ms
4,376 KB
testcase_15 AC 35 ms
4,420 KB
testcase_16 AC 34 ms
4,484 KB
testcase_17 AC 35 ms
4,416 KB
testcase_18 AC 35 ms
4,468 KB
testcase_19 AC 35 ms
4,532 KB
testcase_20 AC 35 ms
4,464 KB
testcase_21 AC 35 ms
4,612 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 35 ms
4,780 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> A(n);
    for(int i = 0; n > i; i++){
        cin>>A[i];
    }
    if(A[0] > A[n-1]){
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
    int nw = A[0];
    vector<int> ret;
    vector<int> ret2;
    for(int i = 1; n-1 > i; i++){
        if(nw < A[i]){
            ret.push_back(A[i]);
        }else{
            ret2.push_back(nw);
            nw = A[i];
        }
    }
    vector<int> o;
    for(int i = 0; ret.size() > i; i++)o.push_back(ret[i]);
    o.push_back(nw);
    for(int i = ret2.size()-1; 0 <= i; i--)o.push_back(ret2[i]);
    for(int i = 0; o.size() > i; i++){
        cout << o[i] << " \n"[i==o.size()-1];
    }
    
}
0