結果

問題 No.649 ここでちょっとQK!
ユーザー tabataba
提出日時 2024-07-31 10:56:03
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,213 bytes
コンパイル時間 12,684 ms
コンパイル使用メモリ 404,552 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-07-31 10:56:44
合計ジャッジ時間 40,761 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
12,960 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 247 ms
6,940 KB
testcase_04 AC 57 ms
9,088 KB
testcase_05 AC 75 ms
9,088 KB
testcase_06 AC 72 ms
9,088 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 57 ms
6,940 KB
testcase_13 AC 51 ms
6,940 KB
testcase_14 AC 52 ms
6,940 KB
testcase_15 AC 368 ms
6,940 KB
testcase_16 AC 745 ms
6,940 KB
testcase_17 AC 1,720 ms
6,940 KB
testcase_18 AC 2,045 ms
6,940 KB
testcase_19 AC 2,418 ms
6,940 KB
testcase_20 AC 2,776 ms
6,940 KB
testcase_21 AC 2,989 ms
6,944 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `HashMap`, `HashSet`, `VecDeque`
 --> src/main.rs:2:29
  |
2 |     collections::{BTreeSet, HashMap, HashSet, VecDeque},
  |                             ^^^^^^^  ^^^^^^^  ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `proconio::marker::Chars`
 --> src/main.rs:8:5
  |
8 | use proconio::marker::Chars;
  |     ^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

use std::{
    collections::{BTreeSet, HashMap, HashSet, VecDeque},
    fmt::Debug,
    io::stdin,
    str::FromStr,
};

use proconio::marker::Chars;

fn main() {
    // proconio::input! {
    //     q: usize,
    //     k: usize,
    // }
    let x = read::<u64>();
    let (q, k) = (x[0], x[1]);
    let mut query = (0..q)
        .flat_map(|_| read::<u64>())
        .enumerate()
        .map(|v| (v.1, v.0));
    let mut s = BTreeSet::new();
    while let Some(q) = query.next() {
        match q.0 {
            1 => {
                let val = query.next().unwrap();
                s.insert(val);
            }
            2 => {
                if s.len() < k as usize {
                    println!("-1");
                } else {
                    let val = s.iter().skip(k as usize - 1).next().unwrap().clone();
                    println!("{}", val.0);
                    s.remove(&val);
                }
            }
            _ => unreachable!(),
        }
    }
}

fn read<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.split(' ').map(|v| v.trim().parse().expect(v)).collect()
}
0