結果
問題 |
No.3298 K-th Slime
|
ユーザー |
![]() |
提出日時 | 2025-10-05 13:56:44 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 1,556 bytes |
コンパイル時間 | 11,130 ms |
コンパイル使用メモリ | 398,024 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-05 13:57:03 |
合計ジャッジ時間 | 13,426 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#![allow(unused_imports)] fn main() { input! { n: usize, k: usize, q: usize, a: [u64; n], } let mut big: BinaryHeap<_> = a.into_iter().map(Reverse).collect(); let mut small = BinaryHeap::new(); for _ in 1..k { small.push(big.pop().unwrap().0); } for _ in 0..q { input! { q: usize, } match q { 1 => { input! { x: u64, } small.push(x); big.push(Reverse(small.pop().unwrap())); } 2 => { input! { y: u64, } let v = Reverse(big.pop().unwrap().0 + y); big.push(v); } 3 => { println!("{}", big.peek().unwrap().0); } _ => unreachable!(), } } } use proconio::{input, marker::*}; use std::{cmp::Reverse, collections::*}; #[macro_export] macro_rules! chmax { ($a:expr, $b:expr) => {{ let tmp = $b; if $a < tmp { $a = tmp; true } else { false } }}; } #[macro_export] macro_rules! chmin { ($a:expr, $b:expr) => {{ let tmp = $b; if $a > tmp { $a = tmp; true } else { false } }}; } #[macro_export] /// mvec![] macro_rules! mvec { ($val:expr; ()) => { $val }; ($val:expr; ($size:expr $(,$rest:expr)*)) => { vec![mvec![$val; ($($rest),*)]; $size] }; }