結果

問題 No.2227 King Kraken's Attack
ユーザー maguroflymagurofly
提出日時 2023-02-24 22:41:36
言語 Rust
(1.77.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,770 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 156,156 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 09:33:13
合計ジャッジ時間 3,118 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 63 ms
6,940 KB
testcase_15 AC 63 ms
6,940 KB
testcase_16 AC 64 ms
6,940 KB
testcase_17 AC 96 ms
6,940 KB
testcase_18 AC 47 ms
6,944 KB
testcase_19 AC 58 ms
6,940 KB
testcase_20 AC 58 ms
6,940 KB
testcase_21 AC 58 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 52 ms
6,944 KB
testcase_25 AC 53 ms
6,944 KB
testcase_26 AC 63 ms
6,940 KB
testcase_27 AC 47 ms
6,940 KB
testcase_28 AC 57 ms
6,940 KB
testcase_29 AC 57 ms
6,944 KB
testcase_30 AC 59 ms
6,940 KB
testcase_31 AC 54 ms
6,940 KB
testcase_32 AC 43 ms
6,944 KB
testcase_33 AC 28 ms
6,940 KB
testcase_34 AC 16 ms
6,944 KB
testcase_35 AC 42 ms
6,944 KB
testcase_36 AC 21 ms
6,944 KB
testcase_37 AC 11 ms
6,944 KB
testcase_38 AC 14 ms
6,944 KB
testcase_39 AC 17 ms
6,944 KB
testcase_40 AC 12 ms
6,940 KB
testcase_41 AC 47 ms
6,944 KB
testcase_42 AC 10 ms
6,944 KB
testcase_43 AC 11 ms
6,940 KB
testcase_44 AC 41 ms
6,944 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#![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] }); }
0