結果
問題 |
No.2923 Mayor's Job
|
ユーザー |
![]() |
提出日時 | 2024-10-12 17:47:18 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,294 bytes |
コンパイル時間 | 14,500 ms |
コンパイル使用メモリ | 400,140 KB |
実行使用メモリ | 22,016 KB |
最終ジャッジ日時 | 2024-10-12 17:47:34 |
合計ジャッジ時間 | 14,670 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#![allow(non_snake_case, unused_must_use, unused_imports)] use std::io::{self, prelude::*}; fn main() { let (stdin, stdout) = (io::read_to_string(io::stdin()).unwrap(), io::stdout()); let (mut stdin, mut buffer) = (stdin.split_whitespace(), io::BufWriter::new(stdout.lock())); macro_rules! input { ($t: ty, $n: expr) => { (0..$n).map(|_| input!($t)).collect::<Vec<_>>() }; ($t: ty) => { stdin.next().unwrap().parse::<$t>().unwrap() }; } let N = input!(usize); let K = input!(isize); let H = input!(usize, N); let mut X = vec![]; let mut Y = vec![]; for _ in 0..N { let x = input!(isize); let y = input!(isize); X.push(x); Y.push(y); } let mut graph = vec![vec![]; N]; for i in 0..N { for j in 0..N { if H[i] < H[j] { let (xi, yi) = (X[i], Y[i]); let (xj, yj) = (X[j], Y[j]); let dx = (xi - xj).abs(); let dy = (yi - yj).abs(); if dx * dx + dy * dy <= K * K { graph[i].push(j); } } } } let ans = graph.iter().filter(|adj| adj.is_empty()).count(); writeln!(buffer, "{}", ans); }