complete 2805.rs 4366.rs 6235.rs 31614.rs 34412.rs
This commit is contained in:
34
storage/zeta/rs/completed/6235.rs
Normal file
34
storage/zeta/rs/completed/6235.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
collections::BinaryHeap,
|
||||
fmt::Binary,
|
||||
io::{read_to_string, stdin},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let mut line = String::new();
|
||||
|
||||
let mut heap = BinaryHeap::new();
|
||||
|
||||
loop {
|
||||
line.clear();
|
||||
stdin().read_line(&mut line).unwrap();
|
||||
if line.starts_with('#') {
|
||||
break;
|
||||
}
|
||||
let mut iter = line.trim().split(' ');
|
||||
iter.next();
|
||||
let q = iter.next().unwrap().parse::<usize>().unwrap();
|
||||
let p = iter.next().unwrap().parse::<usize>().unwrap();
|
||||
heap.push(Reverse((p, q, p)))
|
||||
}
|
||||
|
||||
line.clear();
|
||||
stdin().read_line(&mut line).unwrap();
|
||||
let k = line.trim().parse::<usize>().unwrap();
|
||||
for i in 0..k {
|
||||
let (curr, q, period) = (heap.pop().unwrap()).0;
|
||||
heap.push(Reverse((curr + period, q, period)));
|
||||
println!("{}", q);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user