アルゴリズムと数学 065

https://atcoder.jp/contests/math-and-algorithm/tasks/panasonic2020_b

HWが偶数と奇数で変わりますが、HかWが1のときは身動きが取れないので特殊ですね。

// Bishop
#![allow(non_snake_case)]


//////////////////// library ////////////////////

fn read<T: std::str::FromStr>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect()
}


//////////////////// process ////////////////////

fn read_input() -> (usize, usize) {
    let v = read_vec();
    let H = v[0];
    let W = v[1];
    (H, W)
}

fn f(H: usize, W: usize) -> usize {
    if H == 1 || W == 1 {
        1
    }
    else {
        (H * W + 1) / 2
    }
}

fn main() {
    let (H, W) = read_input();
    println!("{}", f(H, W))
}