結果

問題 No.2210 equence Squence Seuence
ユーザー Manuel1024Manuel1024
提出日時 2023-02-10 21:53:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 803 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 79,312 KB
実行使用メモリ 9,112 KB
最終ジャッジ日時 2023-09-21 23:03:06
合計ジャッジ時間 9,887 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for(auto &it: a) cin >> it;

    vector<bool> u(n);
    for(int i = 0; i < n;){
        int j = i;
        while(j+1 < n && a[j] == a[j+1]) j++;
        bool res = true;
        if(j+1 < n) res = a[j] < a[j+1];
        for(int l = i; l <= j; l++) u[l] = res;
        i = j+1;
    }

    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i;
    sort(v.begin(), v.end(), [&](int x, int y){
        return u[min(x, y)];
    });
    vector<int> ans;
    for(int i = 0; i < n; i++){
        if(v[k-1] == i) continue;
        ans.emplace_back(a[i]);
    }
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i == ans.size()-1];
    return 0;
}
0