結果

問題 No.2210 equence Squence Seuence
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-05 08:03:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,263 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 114,520 KB
実行使用メモリ 6,744 KB
最終ジャッジ日時 2024-05-02 06:56:09
合計ジャッジ時間 4,763 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 18 ms
5,376 KB
testcase_04 AC 21 ms
5,376 KB
testcase_05 AC 31 ms
5,376 KB
testcase_06 AC 28 ms
5,376 KB
testcase_07 AC 69 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 86 ms
5,632 KB
testcase_14 AC 87 ms
5,888 KB
testcase_15 AC 85 ms
5,632 KB
testcase_16 AC 84 ms
5,632 KB
testcase_17 AC 85 ms
5,632 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 67 ms
6,492 KB
testcase_24 AC 51 ms
5,376 KB
testcase_25 AC 60 ms
6,136 KB
testcase_26 AC 79 ms
6,744 KB
testcase_27 AC 24 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    int N, K, c;
    cin >> N >> K; K--;
    vector<int> A(N), p(N, -1), q;
    deque<int> v(N);
    for (int i=0; i<N; i++) v[i] = i;
    for (int i=0; i<N; i++) cin >> A[i];

    for (int i=0; i<N-1; i++){
        q.push_back(i);
        if (A[i] == A[i+1]) continue;
        if (A[i] < A[i+1]){
            while(!q.empty()){
                c = q.back();
                q.pop_back();
                p[c] = v.back();
                v.pop_back();
            }
        }
        else{
            while(!q.empty()){
                c = q.back();
                q.pop_back();
                p[c] = v.front();
                v.pop_front();
            }
        }
    }

    while(!q.empty()){
        c = q.back();
        q.pop_back();
        p[c] = v.front();
        v.pop_front();
    }
    for (int i=0; i<N; i++) if (p[i] == -1) p[i] = v[0];

    for (int i=0; i<N; i++){
        if (K == p[i]) continue;
        cout << A[i] << " ";
    }
    cout << endl;

    return 0;
}
0