#![allow(non_snake_case, unused_imports)] use proconio::{fastout, input, marker::*}; #[fastout] fn main() { input! { N: usize, ABCDE: [[isize; 5]; N], } let mut evals = vec![]; for p in ABCDE { let mut es = vec![]; for s in 0..1 << 5 { let mut e = 0; for i in 0..5 { if (s >> i) & 1 == 1 { e += p[i]; } else { e -= p[i]; } } es.push(e); } evals.push(es); } let mut emin = vec![isize::MAX; 1 << 5]; let mut emax = vec![isize::MIN; 1 << 5]; for ev in evals.iter() { for i in 0..1 << 5 { emin[i] = std::cmp::min(emin[i], ev[i]); emax[i] = std::cmp::max(emax[i], ev[i]); } } for ev in evals { let mut ans = 0; for i in 0..1 << 5 { ans = std::cmp::max(ans, isize::abs_diff(ev[i], emin[i])); ans = std::cmp::max(ans, isize::abs_diff(ev[i], emax[i])); } println!("{}", ans); } }