#[allow(unused)] use proconio::{input, marker::Chars}; fn main() { input! { n: usize, mut t: i32, mut tm: [i32; n - 1], k: usize, x: [usize; k], } tm.insert(0, 0); for i in 1..n { tm[i] += tm[i - 1]; } let mut cnt = 0; for i in 1..n { let mut flg = false; if let Ok(_) = x.binary_search(&i) { flg = true; } if t > tm[i] - tm[i - 1] { if t <= tm[n - 1] - tm[i - 1] && flg { t += 10; cnt += 1; } } else if flg { t += 10; cnt += 1; } else { println!("-1"); return; } t -= tm[i] - tm[i - 1]; } println!("{}", cnt) }