結果
問題 |
No.3042 拡大コピー
|
ユーザー |
|
提出日時 | 2025-02-28 23:17:35 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 870 bytes |
コンパイル時間 | 11,913 ms |
コンパイル使用メモリ | 400,660 KB |
実行使用メモリ | 26,000 KB |
最終ジャッジ日時 | 2025-03-01 07:42:01 |
合計ジャッジ時間 | 13,512 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 24 |
ソースコード
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)) .min_by(|x, y| x.partial_cmp(y).unwrap()) .unwrap() }