結果
問題 |
No.649 ここでちょっとQK!
|
ユーザー |
|
提出日時 | 2024-07-31 10:46:53 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,138 bytes |
コンパイル時間 | 12,658 ms |
コンパイル使用メモリ | 389,108 KB |
実行使用メモリ | 14,024 KB |
最終ジャッジ日時 | 2024-07-31 10:47:12 |
合計ジャッジ時間 | 18,402 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 4 TLE * 1 -- * 27 |
コンパイルメッセージ
warning: unused imports: `BTreeSet`, `HashMap`, `HashSet`, `VecDeque` --> src/main.rs:2:19 | 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; | ^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
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>()); let mut s = Vec::new(); while let Some(q) = query.next() { match q { 1 => { let val = query.next().unwrap(); let p = s.partition_point(|&a| a < val); s.insert(p, val); } 2 => { if s.len() < k as usize { println!("-1"); } else { let val = s.remove(k as usize - 1); println!("{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() }