アルゴリズムと数学 064

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

問題58と同じですね。

// All Zero
#![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()
}

fn YesNo(b: bool) -> String {
    return if b { "Yes".to_string() } else { "No".to_string() }
}


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

fn read_input() -> (i32, Vec<i32>) {
    let v = read_vec();
    let K = v[1];
    let A = read_vec();
    (K, A)
}

fn f(K: i32, A: Vec<i32>) -> bool {
    let s: i32 = A.into_iter().sum();
    s <= K && (K - s) % 2 == 0
}

fn main() {
    let (K, A) = read_input();
    println!("{}", YesNo(f(K, A)))
}