結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
QiToY
|
| 提出日時 | 2026-02-28 14:32:08 |
| 言語 | Rust (1.93.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 3,000 ms |
| コード長 | 1,779 bytes |
| 記録 | |
| コンパイル時間 | 2,029 ms |
| コンパイル使用メモリ | 204,372 KB |
| 実行使用メモリ | 9,568 KB |
| 最終ジャッジ日時 | 2026-02-28 14:32:19 |
| 合計ジャッジ時間 | 8,569 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#![allow(unused_imports)]
fn main() {
input! {
n: usize, mut y: u64, z: u64,
s: [(u64, u64, u64); n],
}
let mut que: BinaryHeap<_> = s.into_iter().map(|(c, l, x)| (Reverse(l), c, x)).collect();
let mut que2 = BinaryHeap::new();
let mut ans = 0;
loop {
let mut nxt = u64::MAX;
while let Some((Reverse(l), c, x)) = que.pop() {
if l > y {
que.push((Reverse(l), c, x));
nxt = l;
break;
}
que2.push((x, c));
}
nxt = nxt.min(z);
while y < nxt {
let Some((x, c)) = que2.pop() else {
break;
};
let d = (nxt-y).div_ceil(x).min(c);
ans += d;
y = z.min(y+d*x);
if d < c {
que2.push((x, c-d));
}
}
if y >= z {
println!("{ans}");
return;
}
if y < nxt {
println!("-1");
return;
}
}
}
use proconio::{input, marker::*};
use itertools::{iproduct, izip, Itertools as _};
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]
};
}
QiToY