結果

問題 No.2210 equence Squence Seuence
ユーザー ぷらぷら
提出日時 2023-02-10 21:39:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 1,008 bytes
コンパイル時間 3,777 ms
コンパイル使用メモリ 205,712 KB
実行使用メモリ 7,164 KB
最終ジャッジ日時 2023-09-21 22:44:51
合計ジャッジ時間 6,674 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 49 ms
4,376 KB
testcase_04 AC 60 ms
4,376 KB
testcase_05 AC 91 ms
4,612 KB
testcase_06 AC 80 ms
4,380 KB
testcase_07 AC 217 ms
6,452 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 309 ms
7,164 KB
testcase_14 AC 279 ms
7,044 KB
testcase_15 AC 257 ms
6,972 KB
testcase_16 AC 258 ms
6,976 KB
testcase_17 AC 279 ms
7,040 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 42 ms
5,304 KB
testcase_24 AC 31 ms
4,548 KB
testcase_25 AC 37 ms
5,204 KB
testcase_26 AC 49 ms
5,560 KB
testcase_27 AC 14 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<int>A,B;

bool f(int i,int j) {
    if(i == j) {
        return false;
    }
    bool s = false;
    if(i > j) {
        s = true;
        swap(i,j);
    }
    int it = upper_bound(B.begin(),B.end(),i)-B.begin();
    if(it == B.size() || B[it] > j) return false;
    if(A[B[it]-1] < A[B[it]]) {
        if(!s) return false;
        else return true;
    }
    if(!s) return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    A.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(i && A[i-1] != A[i]) {
            B.push_back(i);
        }
    }
    vector<int>ans(N);
    iota(ans.begin(),ans.end(),0);
    sort(ans.begin(),ans.end(),f);
    vector<int>X;
    for(int i = 0; i < N; i++) {
        if(i == ans[K-1]) continue;
        X.push_back(A[i]);
    }
    for(int i = 0; i < N-1; i++) {
        cout << X[i] << ((i+1 == N-1)?"\n":" ");
    }
}
0