fn main() { input!{ n: usize, f: usize, a: [usize; n], b: [usize; n], c: [usize; n], } let max_f = 3*n*f; // dp[i番目まで見た][指の合計本数j] = true/false let mut cur_dp = vec![false; max_f+1]; cur_dp[0] = true; // もらうDP for i in 1..=n { let mut ans = 0; for next in (0..=max_f).rev() { if next >= a[i-1] { cur_dp[next] |= cur_dp[next - a[i-1]]; } if next >= b[i-1] { cur_dp[next] |= cur_dp[next - b[i-1]]; } if next >= c[i-1] { cur_dp[next] |= cur_dp[next - c[i-1]]; } } for j in 0..=max_f { if cur_dp[j] { ans += 1;} } println!("{}", ans); } } // const MOD17: usize = 1000000007; // const MOD93: usize = 998244353; // const INF: usize = 1 << 60; // let dx = vec![!0, 0, 1, 0]; // 上左下右 // let dy = vec![0, !0, 0, 1]; // 上左下右 // let d = vec!{(!0, 0), (0, !0), (1, 0), (0, 1)}; // 上左下右 #[allow(unused)] use proconio::{input, marker::Chars, marker::Usize1}; #[allow(unused)] use std::{ mem::swap, cmp::min, cmp::max, cmp::Reverse, collections::HashSet, collections::BTreeSet, collections::HashMap, collections::BTreeMap, collections::BinaryHeap, collections::VecDeque, iter::FromIterator, };