結果

問題 No.2210 equence Squence Seuence
ユーザー jianglyjiangly
提出日時 2023-02-10 21:28:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 1,138 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 204,992 KB
実行使用メモリ 5,452 KB
最終ジャッジ日時 2023-09-21 22:31:36
合計ジャッジ時間 4,983 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 9 ms
4,376 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 14 ms
4,376 KB
testcase_06 AC 12 ms
4,376 KB
testcase_07 AC 32 ms
4,808 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 39 ms
5,340 KB
testcase_14 AC 40 ms
5,452 KB
testcase_15 AC 40 ms
5,324 KB
testcase_16 AC 39 ms
5,388 KB
testcase_17 AC 40 ms
5,372 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 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 41 ms
4,812 KB
testcase_24 AC 30 ms
4,380 KB
testcase_25 AC 36 ms
4,528 KB
testcase_26 AC 49 ms
5,336 KB
testcase_27 AC 14 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n, k;
    std::cin >> n >> k;
    
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    std::vector<int> lc(n);
    lc[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        if (a[i] == a[i + 1]) {
            lc[i] = lc[i + 1] + 1;
        } else {
            lc[i] = 0;
        }
    }
    
    auto cmp = [&](int i, int j) {
        int l = lc[std::min(i, j)];
        
        if (l == std::abs(i - j)) {
            return false;
        }
        
        if (i < j) {
            return a[i + 1 + l] < a[i + l];
        } else {
            return a[j + l] < a[j + 1 + l];
        }
    };
    
    std::vector<int> order(n);
    std::iota(order.begin(), order.end(), 0);
    k--;
    std::nth_element(order.begin(), order.begin() + k, order.end(), cmp);
    
    int x = order[k];
    for (int i = 0; i < n; i++) {
        if (x != i) {
            std::cout << a[i] << " ";
        }
    }
    std::cout << "\n";
    
    return 0;
}
0