結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
|
提出日時 | 2021-01-23 18:13:14 |
言語 | Crystal (1.14.0) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 495 bytes |
コンパイル時間 | 12,118 ms |
コンパイル使用メモリ | 297,040 KB |
実行使用メモリ | 34,712 KB |
最終ジャッジ日時 | 2024-06-30 22:08:47 |
合計ジャッジ時間 | 14,596 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
n = gets.to_s.to_i xy = Array.new(n){ gets.to_s.split.map { |v| v.to_i64 - 1} } dists = [] of Tuple(Int64,Int32,Int32) n.times do |i| n.times do |j| next unless i < j xi,yi = xy[i] xj,yj = xy[j] dist = (yi - yj) ** 2 + (xi - xj) ** 2 dists << {dist, i, j} end end bang = Array.new(n, false) ans = 0_i64 dists.sort.each do |d, i, j| next if bang[i] || bang[j] if i == 0 bang[j] = true ans += 1 else bang[i] = true bang[j] = true end end puts ans