結果

問題 No.2227 King Kraken's Attack
ユーザー akakimidoriakakimidori
提出日時 2023-01-26 23:48:05
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,420 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 158,820 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 09:15:52
合計ジャッジ時間 6,493 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 225 ms
6,944 KB
testcase_15 AC 208 ms
6,940 KB
testcase_16 AC 198 ms
6,940 KB
testcase_17 AC 249 ms
6,944 KB
testcase_18 WA -
testcase_19 AC 191 ms
6,944 KB
testcase_20 AC 192 ms
6,944 KB
testcase_21 AC 214 ms
6,944 KB
testcase_22 AC 58 ms
6,944 KB
testcase_23 AC 6 ms
6,940 KB
testcase_24 AC 139 ms
6,940 KB
testcase_25 AC 182 ms
6,944 KB
testcase_26 AC 311 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 196 ms
6,944 KB
testcase_29 AC 189 ms
6,940 KB
testcase_30 AC 219 ms
6,944 KB
testcase_31 AC 169 ms
6,940 KB
testcase_32 AC 82 ms
6,944 KB
testcase_33 AC 68 ms
6,944 KB
testcase_34 AC 50 ms
6,948 KB
testcase_35 AC 89 ms
6,944 KB
testcase_36 AC 87 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    input! {
        h: i64,
        w: i64,
        x: i64,
        y: i64,
        a: i64,
        b: i64,
    }
    let mut row = (h, x, a);
    let mut col = (w, y, b);
    let mut ans = std::i64::MAX;
    for _ in 0..2 {
        let (h, x, a) = row;
        let (w, y, b) = col;
        let can = |i: i64, j: i64| -> bool {
            let free = a * i + j * b;
            let rect = (i * x).min(h) * (j * y).min(w);
            rect + free >= h * w
        };
        for i in 0..=h {
            let mut ok = h * w;
            let mut ng = -1;
            while ok - ng > 1 {
                let mid = (ok + ng) / 2;
                if can(i, mid) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            if can(i, ok) {
                ans = ans.min(i + ok);
            }
        }
        std::mem::swap(&mut row, &mut col);
    }
    println!("{}", ans);
}

// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// ---------- end input macro ----------
0