#![allow(unused_macros)] #![allow(dead_code)] #![allow(unused_imports)] // # ファイル構成 // - use 宣言 // - lib モジュール // - main 関数 // - basic モジュール // // 常に使うテンプレートライブラリは basic モジュール内にあります。 // 問題に応じて使うライブラリ lib モジュール内にコピペしています。 // ライブラリのコードはこちら → https://github.com/RheoTommy/at_coder // Twitter はこちら → https://twitter.com/RheoTommy use std::collections::*; use std::io::{stdout, BufWriter, Write}; use crate::basic::*; use crate::lib::*; pub mod lib {} fn main() { let mut sc = Scanner::new(); let n = sc.next_usize(); let m = sc.next_usize(); let x = sc.next_usize(); let y = sc.next_usize(); let z = sc.next_usize(); let a = sc .next_vec::(n) .into_iter() .filter(|ai| *ai > y) .collect::>(); let n = a.len(); let mut dp = vec![vec![vec![0; 5000]; n + 1]; n + 1]; dp[0][0][0] = 1; for i in 0..n { for j in 0..n { for sum in 0..=2500 { if a[i] >= x { dp[i + 1][j + 1][sum + a[i]] += dp[i][j][sum]; } else { dp[i + 1][j + 1][sum + a[i]] += dp[i][j][sum]; dp[i + 1][j][sum] += dp[i][j][sum]; } } } } let mut ans = 0; for j in 1..=m.min(n) { ans += dp[n][j][j * z]; } if dp[n] .iter() .take(n.min(m) + 1) .flat_map(|vi| vi) .sum::() == 0 { println!("Handicapped"); } else { println!("{}", ans); } } pub mod basic { pub const U_INF: u64 = (1 << 60) + (1 << 30); pub const I_INF: i64 = (1 << 60) + (1 << 30); pub struct Scanner { buf: std::collections::VecDeque, reader: std::io::BufReader, } impl Scanner { pub fn new() -> Self { Self { buf: std::collections::VecDeque::new(), reader: std::io::BufReader::new(std::io::stdin()), } } fn scan_line(&mut self) { use std::io::BufRead; let mut flag = 0; while self.buf.is_empty() { let mut s = String::new(); self.reader.read_line(&mut s).unwrap(); let mut iter = s.split_whitespace().peekable(); if iter.peek().is_none() { if flag >= 5 { panic!("There is no input!"); } flag += 1; continue; } for si in iter { self.buf.push_back(si.to_string()); } } } pub fn next(&mut self) -> T { self.scan_line(); self.buf .pop_front() .unwrap() .parse() .unwrap_or_else(|_| panic!("Couldn't parse!")) } pub fn next_usize(&mut self) -> usize { self.next() } pub fn next_int(&mut self) -> i64 { self.next() } pub fn next_uint(&mut self) -> u64 { self.next() } pub fn next_chars(&mut self) -> Vec { self.next::().chars().collect() } pub fn next_string(&mut self) -> String { self.next() } pub fn next_char(&mut self) -> char { self.next() } pub fn next_float(&mut self) -> f64 { self.next() } pub fn next_vec(&mut self, n: usize) -> Vec { (0..n).map(|_| self.next()).collect::>() } } }