結果
| 問題 | No.3681 心の沸騰石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 13:53:30 |
| 言語 | Rust (1.97.1 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 0 ms / 2,000 ms |
| + 831µs | |
| コード長 | 1,680 bytes |
| 記録 | |
| コンパイル時間 | 862 ms |
| コンパイル使用メモリ | 200,360 KB |
| 実行使用メモリ | 9,788 KB |
| 最終ジャッジ日時 | 2026-09-05 13:54:43 |
| 合計ジャッジ時間 | 2,590 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
ソースコード
pub use __cargo_equip::prelude::*;
use cplib_search_binary_search::binary_search;
use proconio::{fastout, input};
#[fastout]
fn main() {
input! {
r: usize,
p: usize,
q: usize,
a: [usize; 4],
}
let sum = a.iter().sum::<usize>();
let checker = |x: usize| {
if x * 3 > sum {
return false;
}
let mut cost = x * p;
for i in 0..3 {
cost += x.saturating_sub(a[i]) * q;
}
cost <= r
};
let ans = binary_search(0, 2_000_000_000, checker);
println!("{}", ans);
}
// The following code was expanded by `cargo-equip`.
/// # Bundled libraries
///
/// - `git+https://github.com/cacampu/cplib-rs#binary-search@0.1.0` licensed under `MIT` as `crate::__cargo_equip::crates::cplib_search_binary_search`
#[cfg_attr(any(), rustfmt::skip)]
#[allow(unused)]
mod __cargo_equip {
pub(crate) mod crates {
pub mod cplib_search_binary_search {pub trait Bisect:Clone{fn middle_point(&self,rhs:&Self)->Option<Self>;}macro_rules!impl_bisect{($($t:ty),*)=>{$(impl Bisect for$t{fn middle_point(&self,rhs:&Self)->Option<Self>{if self.abs_diff(*rhs)>1{Some(self.midpoint(*rhs))}else{None}}})*};}impl_bisect!(usize,isize,u8,u16,u32,u64,u128,i8,i16,i32,i64,i128);pub fn binary_search<T:Bisect>(mut ok:T,mut ng:T,mut checker:impl FnMut(T)->bool)->T{while let Some(m)=ok.middle_point(&ng){if checker(m.clone()){ok=m;}else{ng=m;}}ok}}
}
pub(crate) mod macros {
pub mod cplib_search_binary_search {}
}
pub(crate) mod prelude {pub use crate::__cargo_equip::crates::*;}
mod preludes {
pub mod cplib_search_binary_search {}
}
}