use std::collections::*; use std::io::Write; type Map = BTreeMap; type Set = BTreeSet; type Deque = VecDeque; fn run() { input! { n: usize, p: [(i64, i64); n], } let mut point = p; point.sort(); if point.len() > 2 { let sign = |a: usize, b: usize, c: usize| -> i64 { let a = point[a]; let b = point[b]; let c = point[c]; let ab = (b.0 - a.0, b.1 - a.1); let bc = (c.0 - b.0, c.1 - b.1); ab.0 * bc.1 - ab.1 * bc.0 }; let n = point.len(); let mut hull = vec![0]; let mut fix = 0; for i in (1..n).chain((0..(n - 1)).rev()) { while hull.len() > fix + 1 { let len = hull.len(); if sign(hull[len - 2], hull[len - 1], i) >= 0 { hull.pop(); } else { break; } } hull.push(i); if i == n - 1 { fix = hull.len() - 1; } } hull.pop(); point = hull.into_iter().map(|k| point[k]).collect(); } let mut p = point; let mut ans = 0; for _ in 0..2 { argument_sort(&mut p); let mut pos = 0; for i in 0..n { let (x, y) = p[i]; let mut f = |p: (i64, i64)| -> i64 { let s = x * p.1 - y * p.0; ans = ans.max(s.abs()); s }; if pos == i { pos = (pos + 1) % n; } while pos != i { let a = p[pos]; let b = p[(pos + 1) % n]; if f(a) <= f(b) { pos = (pos + 1) % n; } else { break; } } } p.iter_mut().for_each(|p| p.1 *= -1); } println!("{}", ans); } // https://judge.yosupo.jp/submission/27030 より pub fn argument_sort(a: &mut [(i64, i64)]) { a.sort_by(|&(x1, y1), &(x2, y2)| { (y1 >= 0) .cmp(&(y2 >= 0)) .then_with(|| (x2 as i64 * y1 as i64).cmp(&(x1 as i64 * y2 as i64))) .then_with(|| y1.cmp(&y2)) // (0, 0) < (x, y (> 0)) .then_with(|| x2.cmp(&x1)) // (x1 (>= 0), 0) < (x2 (< 0), 0) }); } fn main() { run(); } // ---------- begin input macro ---------- // reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[macro_export] macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ----------