結果
問題 | No.1265 Balloon Survival |
ユーザー |
![]() |
提出日時 | 2020-10-24 08:57:39 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 1,105 ms / 2,000 ms |
コード長 | 1,038 bytes |
コンパイル時間 | 13,596 ms |
コンパイル使用メモリ | 443,196 KB |
実行使用メモリ | 108,164 KB |
最終ジャッジ日時 | 2024-07-21 14:57:54 |
合計ジャッジ時間 | 35,730 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
Main.kt:42:13: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator. builder.appendln(ans) ^
ソースコード
import java.util.*fun main() {val builder = StringBuilder()val n = readInputLine().toInt()val balloon = Array(n) {val (x, y) = readInputLine().split(" ").map { it.toLong() }Pair(x, y)}val queue = PriorityQueue<Triple<Int, Int, Long>> { x, y -> x.third.compareTo(y.third) }for (i in 0 until n) {for (j in i + 1 until n) {val x = balloon[i].first - balloon[j].firstval y = balloon[i].second - balloon[j].secondqueue.add(Triple(i, j, x * x + y * y))}}var ans = 0val removed = BooleanArray(n)while (queue.isNotEmpty()) {val (x, y, _) = queue.poll()!!if (removed[x] || removed[y]) {continue}if (x == 0 && !removed[y]) {ans++}if (x != 0) {removed[x] = true}removed[y] = true}builder.appendln(ans)print(builder.toString())}fun readInputLine(): String {return readLine()!!}