結果
問題 | No.1265 Balloon Survival |
ユーザー |
|
提出日時 | 2021-11-02 10:37:14 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 549 bytes |
コンパイル時間 | 60 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 49,676 KB |
最終ジャッジ日時 | 2024-10-11 08:51:10 |
合計ジャッジ時間 | 10,191 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 TLE * 10 |
コンパイルメッセージ
Main.rb:27: warning: assigned but unused variable - d Syntax OK
ソースコード
n = gets.to_i xy = [] n.times { xy << gets.split(" ").map{|s| s.to_i} } dist = [] max = 0 0.upto(n-1) {|i| xi, yi = xy[i] (i+1).upto(n-1) {|j| xj, yj = xy[j] d = (xi-xj)**2 + (yi-yj)**2 max = d if i == 0 and max < d dist << [d, i, j] if d <= max } } dist.sort! alive = Array.new(n, true) alive_n = n remove = 0 while alive_n > 1 do d, i, j = dist.shift if i == 0 and alive[j] then remove += 1 alive[j] = false alive_n -= 1 elsif alive[i] and alive[j] then alive[i] = alive[j] = false alive_n -= 2 end end puts remove