結果
問題 | 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_ixy = []n.times {xy << gets.split(" ").map{|s| s.to_i}}dist = []max = 00.upto(n-1) {|i|xi, yi = xy[i](i+1).upto(n-1) {|j|xj, yj = xy[j]d = (xi-xj)**2 + (yi-yj)**2max = d if i == 0 and max < ddist << [d, i, j] if d <= max}}dist.sort!alive = Array.new(n, true)alive_n = nremove = 0while alive_n > 1 dod, i, j = dist.shiftif i == 0 and alive[j] thenremove += 1alive[j] = falsealive_n -= 1elsif alive[i] and alive[j] thenalive[i] = alive[j] = falsealive_n -= 2endendputs remove