結果
| 問題 |
No.2227 King Kraken's Attack
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-24 22:41:36 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,770 bytes |
| コンパイル時間 | 13,125 ms |
| コンパイル使用メモリ | 376,288 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-02 11:22:01 |
| 合計ジャッジ時間 | 15,999 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 WA * 1 |
ソースコード
#![allow(dead_code, unused_imports, unused_macros, non_snake_case)]
use std::collections::btree_map::VacantEntry;
fn main() {
let mut input = Input::new();
let H = input.read::<i64>();
let W = input.read::<i64>();
let LA = input.read::<i64>();
let LB = input.read::<i64>();
let KA = input.read::<i64>();
let KB = input.read::<i64>();
let mut ans = INF;
for count_hpunch in 0 ..= H {
let hattacked = H.min(count_hpunch * LA);
let mut ac = W;
let mut wa = -1;
while ac - wa > 1 {
let wj = (ac + wa) / 2;
let vattacked = W.min(wj * LB);
let rem = H * W - hattacked * vattacked;
if rem <= KA * count_hpunch + KB * wj {
ac = wj;
} else {
wa = wj;
}
}
let vattacked = W.min(ac * LB);
if H * W <= hattacked * vattacked + count_hpunch * KA + ac * KB {
ans = ans.min(count_hpunch + ac);
}
}
println!("{}", ans);
}
type Int = i64;
const MOD: Int = 1_000_000_007;
const INF: Int = 1_000_000_000_000_000_000;
const YESNO: [&'static str; 2] = ["Yes", "No"];
pub struct Input {
words: std::collections::VecDeque<String>,
}
impl Input {
pub fn new() -> Self {
use std::io::prelude::*;
let mut stdin = std::io::stdin();
let mut input = String::new();
stdin.read_to_string(&mut input).unwrap();
let words = input.split_ascii_whitespace().map(str::to_string).collect();
Self { words }
}
pub fn read<T: std::str::FromStr>(&mut self) -> T {
let res = self.words.pop_front().unwrap().parse();
if let Ok(r) = res {
r
} else {
panic!("read() failed")
}
}
}
fn yes() { println!("{}", YESNO[0]); }
fn no() { println!("{}", YESNO[1]); }
fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }