結果

問題 No.2923 Mayor's Job
ユーザー yiwiy9
提出日時 2025-01-21 03:27:11
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 18,566 ms
コンパイル使用メモリ 400,400 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-23 14:26:00
合計ジャッジ時間 19,843 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

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

    let mut removed = vec![false; n];

    let mut heap = std::collections::BinaryHeap::new();
    for i in 0..n {
        heap.push((h[i], i));
    }

    while let Some((h_j, j)) = heap.pop() {
        for i in 0..n {
            if i == j {
                continue;
            }
            if h[i] >= h_j {
                continue;
            }

            let (x_i, y_i) = xy[i];
            let (x_j, y_j) = xy[j];
            if (x_i as i64 - x_j as i64) * (x_i as i64 - x_j as i64)
                + (y_i as i64 - y_j as i64) * (y_i as i64 - y_j as i64)
                <= (k * k) as i64
            {
                removed[i] = true;
            }
        }
    }

    println!("{}", removed.iter().filter(|&&r| !r).count());
}
0