#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::*; use std::collections::*; use std::io::Write; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let v = read_vec::(); let (n, mut x, mut y, mut z) = (v[0] as usize, v[1], v[2], v[3]); let mut a = read_vec::() .into_iter() .map(|x| x + 1) .collect::>(); for i in 0..n { let zi = a[i] / 10000; let act_z = min(z, zi); a[i] -= act_z * 10000; z -= act_z; let yi = a[i] / 5000; let act_y = min(y, yi); a[i] -= act_y * 5000; y -= act_y; } // debug!(a, x, y, z); while z > 0 { a.sort(); a.reverse(); for i in 0..n { if a[i] > 0 && z > 0 { a[i] -= 10000; z -= 1; } } } let mut a = a.into_iter().filter(|&x| x > 0).collect::>(); let n = a.len(); for i in 0..n { let yi = a[i] / 5000; let act_y = min(y, yi); a[i] -= act_y * 5000; y -= act_y; } while y > 0 { a.sort(); a.reverse(); for i in 0..n { if a[i] > 0 && y > 0 { a[i] -= 5000; y -= 1; } } } for num in a { if num > 0 { x -= (1000 + num - 1) / 1000; } } if x >= 0 { println!("Yes"); } else { println!("No"); } } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }