use proconio::input; type Coord = (f64, f64); fn main() { input! { n: usize, xy: [(f64, f64); n], zw: [(f64, f64); n], } let max_dist_xy = calc_max_dist(&xy); let max_dist_zw = calc_max_dist(&zw); println!("{}", max_dist_zw / max_dist_xy); } fn calc_center(coords: &[Coord]) -> Coord { let mut sum_x = 0.0; let mut sum_y = 0.0; for &(x, y) in coords { sum_x += x; sum_y += y; } (sum_x / coords.len() as f64, sum_y / coords.len() as f64) } fn calc_dist(coord1: Coord, coord2: Coord) -> f64 { (coord1.0 - coord2.0).abs() + (coord1.1 - coord2.1).abs() } fn calc_max_dist(coords: &[Coord]) -> f64 { let center = calc_center(coords); coords .iter() .map(|&coord| calc_dist(coord, center)) .max_by(|x, y| x.partial_cmp(y).unwrap()) .unwrap() }