結果
問題 | No.2210 equence Squence Seuence |
ユーザー |
|
提出日時 | 2023-02-10 21:28:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 1,138 bytes |
コンパイル時間 | 1,851 ms |
コンパイル使用メモリ | 200,528 KB |
最終ジャッジ日時 | 2025-02-10 12:13:04 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#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; }