fn main() { let (n, x) = input_tuple(); let a_b = input_tuple_vec::(n); let mut list = vec![0; x + 1]; for &(a, b) in &a_b { list[a] = list[a].max(b); let mut light = b; let mut j = a; while light > 0 { light -= 1; j += 1; if j > x { break; } list[j] = list[j].max(light); } let mut light = b; let mut j = a; while light > 0 { light -= 1; j -= 1; if j == 0 { break; } list[j] = list[j].max(light); } // println!("{:?}", list); } let text = &list[1..=x] .iter() .map(|x| x.to_string()) .collect::>() .join(" "); println!("{}", text); } fn input_tuple() -> (T, T) where T: std::str::FromStr, ::Err: std::fmt::Debug, { let stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let mut iter = buf.split_whitespace(); let n = iter.next().unwrap().parse().unwrap(); let m = iter.next().unwrap().parse().unwrap(); (n, m) } fn input_tuple_vec(n: usize) -> Vec<(T, T)> where T: std::str::FromStr, ::Err: std::fmt::Debug, { // タプルのベクタ let stdin = std::io::stdin(); let mut s_t_d = Vec::with_capacity(n); for _ in 0..n { let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let mut iter = buf.split_whitespace(); let s = iter.next().unwrap().parse().unwrap(); let t = iter.next().unwrap().parse().unwrap(); // let d = iter.next().unwrap().parse().unwrap(); s_t_d.push((s, t)); } s_t_d }