結果

問題 No.3042 拡大コピー
ユーザー atcoder8
提出日時 2025-02-28 22:52:48
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 13,700 ms
コンパイル使用メモリ 400,680 KB
実行使用メモリ 33,168 KB
最終ジャッジ日時 2025-03-01 07:40:43
合計ジャッジ時間 12,026 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

type Coord = (f64, f64);

const MAX_COORD: f64 = 1e9;

fn main() {
    input! {
        n: usize,
        xy: [(f64, f64); n],
        zw: [(f64, f64); n],
    }

    let rotated_xy = to_rotated(&xy);
    let rotated_zw = to_rotated(&zw);

    let max_dist_xy = calc_max_dist(&rotated_xy);
    let max_dist_zw = calc_max_dist(&rotated_zw);

    println!("{}", max_dist_zw / max_dist_xy);
}

fn calc_rotated_coord(coord: Coord) -> Coord {
    (coord.0 - coord.1, coord.0 + coord.1)
}

fn to_rotated(coords: &[Coord]) -> Vec<Coord> {
    coords.iter().cloned().map(calc_rotated_coord).collect()
}

fn calc_max_dist(coords: &[Coord]) -> f64 {
    let (mut min_x, mut max_x, mut min_y, mut max_y) = (MAX_COORD, 0.0_f64, MAX_COORD, 0.0_f64);
    for &(x, y) in coords {
        min_x = min_x.min(x);
        max_x = max_x.max(x);
        min_y = min_y.min(y);
        max_y = max_y.max(y);
    }

    (max_x - min_x).max(max_y - min_y)
}
0