結果

問題 No.5017 Tool-assisted Shooting
ユーザー エセ賢者エセ賢者
提出日時 2023-07-16 16:11:42
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 400 ms / 2,000 ms
コード長 2,172 bytes
コンパイル時間 15,243 ms
コンパイル使用メモリ 427,560 KB
実行使用メモリ 70,940 KB
スコア 5,202
平均クエリ数 113.97
最終ジャッジ日時 2023-07-16 16:12:41
合計ジャッジ時間 55,441 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 366 ms
69,524 KB
testcase_01 AC 331 ms
69,408 KB
testcase_02 AC 363 ms
68,924 KB
testcase_03 AC 357 ms
68,776 KB
testcase_04 AC 330 ms
69,416 KB
testcase_05 AC 336 ms
69,204 KB
testcase_06 AC 340 ms
69,852 KB
testcase_07 AC 344 ms
69,496 KB
testcase_08 AC 338 ms
68,820 KB
testcase_09 AC 360 ms
69,132 KB
testcase_10 AC 361 ms
69,008 KB
testcase_11 AC 343 ms
69,028 KB
testcase_12 AC 332 ms
68,992 KB
testcase_13 AC 377 ms
70,104 KB
testcase_14 AC 364 ms
68,988 KB
testcase_15 AC 388 ms
69,352 KB
testcase_16 AC 344 ms
69,040 KB
testcase_17 AC 347 ms
69,440 KB
testcase_18 AC 352 ms
69,160 KB
testcase_19 AC 349 ms
69,304 KB
testcase_20 AC 349 ms
69,572 KB
testcase_21 AC 338 ms
69,268 KB
testcase_22 AC 344 ms
69,624 KB
testcase_23 AC 354 ms
69,520 KB
testcase_24 AC 335 ms
69,464 KB
testcase_25 AC 355 ms
69,188 KB
testcase_26 AC 369 ms
69,392 KB
testcase_27 AC 348 ms
69,576 KB
testcase_28 AC 337 ms
69,032 KB
testcase_29 AC 341 ms
69,856 KB
testcase_30 AC 377 ms
69,664 KB
testcase_31 AC 331 ms
69,208 KB
testcase_32 AC 363 ms
69,224 KB
testcase_33 AC 400 ms
69,724 KB
testcase_34 AC 333 ms
69,252 KB
testcase_35 AC 349 ms
68,840 KB
testcase_36 AC 363 ms
69,096 KB
testcase_37 AC 347 ms
69,300 KB
testcase_38 AC 352 ms
69,116 KB
testcase_39 AC 378 ms
69,024 KB
testcase_40 AC 348 ms
68,880 KB
testcase_41 AC 340 ms
69,184 KB
testcase_42 AC 391 ms
69,248 KB
testcase_43 AC 362 ms
69,168 KB
testcase_44 AC 343 ms
69,732 KB
testcase_45 AC 373 ms
69,376 KB
testcase_46 AC 344 ms
69,320 KB
testcase_47 AC 345 ms
69,420 KB
testcase_48 AC 334 ms
68,816 KB
testcase_49 AC 350 ms
69,252 KB
testcase_50 AC 369 ms
70,904 KB
testcase_51 AC 363 ms
69,336 KB
testcase_52 AC 366 ms
68,912 KB
testcase_53 AC 360 ms
68,932 KB
testcase_54 AC 372 ms
69,288 KB
testcase_55 AC 360 ms
69,224 KB
testcase_56 AC 355 ms
68,992 KB
testcase_57 AC 338 ms
69,192 KB
testcase_58 AC 347 ms
68,932 KB
testcase_59 AC 361 ms
68,992 KB
testcase_60 AC 353 ms
69,292 KB
testcase_61 AC 368 ms
69,652 KB
testcase_62 AC 353 ms
69,248 KB
testcase_63 AC 379 ms
69,144 KB
testcase_64 AC 348 ms
69,348 KB
testcase_65 AC 341 ms
69,524 KB
testcase_66 AC 363 ms
69,612 KB
testcase_67 AC 373 ms
70,940 KB
testcase_68 AC 348 ms
69,500 KB
testcase_69 AC 329 ms
69,468 KB
testcase_70 AC 351 ms
69,132 KB
testcase_71 AC 345 ms
69,004 KB
testcase_72 AC 339 ms
69,380 KB
testcase_73 AC 350 ms
70,008 KB
testcase_74 AC 371 ms
69,148 KB
testcase_75 AC 385 ms
68,976 KB
testcase_76 AC 350 ms
69,504 KB
testcase_77 AC 362 ms
69,744 KB
testcase_78 AC 366 ms
69,576 KB
testcase_79 AC 351 ms
69,156 KB
testcase_80 AC 360 ms
68,940 KB
testcase_81 AC 359 ms
69,212 KB
testcase_82 AC 346 ms
69,636 KB
testcase_83 AC 357 ms
69,380 KB
testcase_84 AC 355 ms
69,568 KB
testcase_85 AC 345 ms
69,412 KB
testcase_86 AC 358 ms
68,896 KB
testcase_87 AC 341 ms
69,108 KB
testcase_88 AC 356 ms
68,984 KB
testcase_89 AC 358 ms
69,264 KB
testcase_90 AC 370 ms
69,608 KB
testcase_91 AC 365 ms
69,096 KB
testcase_92 AC 360 ms
69,436 KB
testcase_93 AC 341 ms
68,804 KB
testcase_94 AC 344 ms
69,240 KB
testcase_95 AC 358 ms
69,616 KB
testcase_96 AC 358 ms
69,564 KB
testcase_97 AC 349 ms
68,904 KB
testcase_98 AC 385 ms
69,024 KB
testcase_99 AC 355 ms
69,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:10:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:45:51: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Enemy
                val near = sameLine.minBy { it.y }!!
                                                  ^

ソースコード

diff #

private fun next() = readLine()!!
private fun nextInt() = next().toInt()
private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextList() = next().split(" ")
private fun nextIntList() = next().split(" ").map { it.toInt() }.toIntArray()
private fun nextLongList() = next().split(" ").map { it.toLong() }.toLongArray()
private fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toDoubleArray()

fun main(args: Array<String>) {
    var turn = 0
    var enemyList = mutableListOf<Enemy>()
    var own = 12
    var power = 100
    while (turn < 1000) {
        val n = nextInt()
        if (n == -1) {
            return
        }
        val newEnemyList = mutableListOf<Enemy>()
        for (enemy in enemyList) {
            val isAlive = enemy.nextTurn()
            if (isAlive) {
                newEnemyList.add(enemy)
            }
        }
        enemyList = newEnemyList
        for (i in 0 until n) {
            val hpx = nextIntList()
            enemyList.add(Enemy(hpx[2], 59, hpx[0], hpx[1]))
        }
        if (enemyList.isEmpty()) {
            println("S")
        } else {
            val sameLine = enemyList.filter { it.x == own }
            if (sameLine.isEmpty()) {
                if (Math.random() < 0.5) {
                    println("R")
                    own++
                } else {
                    println("L")
                    own--
                }
            } else {
                val near = sameLine.minBy { it.y }!!
                if (near.h > near.y * (power / 100)) {
                    if (Math.random() < 0.5) {
                        println("R")
                        own++
                    } else {
                        println("L")
                        own--
                    }
                } else {
                    println("S")
                }
            }
        }
        turn++
    }
}

class Enemy(var x: Int, var y: Int, var h: Int, var p: Int) {
    val maxH = h
    fun nextTurn(): Boolean {
        y--
        return y >= 0
    }

    fun hit(damage: Int): Boolean {
        h -= damage
        return h >= 0
    }
}
0