結果

問題 No.275 中央値を求めよ
ユーザー rutilicusrutilicus
提出日時 2020-08-30 21:19:29
言語 Kotlin
(1.6.10)
結果
AC  
実行時間 282 ms / 1,000 ms
コード長 421 bytes
コンパイル時間 10,289 ms
使用メモリ 52,716 KB
最終ジャッジ日時 2022-12-16 10:24:02
合計ジャッジ時間 23,495 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 261 ms
51,464 KB
testcase_01 AC 253 ms
51,540 KB
testcase_02 AC 253 ms
51,592 KB
testcase_03 AC 254 ms
51,276 KB
testcase_04 AC 254 ms
51,592 KB
testcase_05 AC 261 ms
51,572 KB
testcase_06 AC 253 ms
51,520 KB
testcase_07 AC 268 ms
51,860 KB
testcase_08 AC 249 ms
51,336 KB
testcase_09 AC 255 ms
51,276 KB
testcase_10 AC 262 ms
51,564 KB
testcase_11 AC 236 ms
48,108 KB
testcase_12 AC 250 ms
49,512 KB
testcase_13 AC 258 ms
51,532 KB
testcase_14 AC 244 ms
49,416 KB
testcase_15 AC 273 ms
51,756 KB
testcase_16 AC 274 ms
52,716 KB
testcase_17 AC 269 ms
51,940 KB
testcase_18 AC 257 ms
51,636 KB
testcase_19 AC 258 ms
51,556 KB
testcase_20 AC 263 ms
51,628 KB
testcase_21 AC 275 ms
51,704 KB
testcase_22 AC 258 ms
51,620 KB
testcase_23 AC 259 ms
51,676 KB
testcase_24 AC 259 ms
51,728 KB
testcase_25 AC 267 ms
51,744 KB
testcase_26 AC 258 ms
51,468 KB
testcase_27 AC 261 ms
51,576 KB
testcase_28 AC 251 ms
51,396 KB
testcase_29 AC 253 ms
51,640 KB
testcase_30 AC 252 ms
51,500 KB
testcase_31 AC 258 ms
51,616 KB
testcase_32 AC 263 ms
51,528 KB
testcase_33 AC 282 ms
52,108 KB
testcase_34 AC 257 ms
51,432 KB
testcase_35 AC 269 ms
51,520 KB
testcase_36 AC 265 ms
51,624 KB
testcase_37 AC 253 ms
51,608 KB
testcase_38 AC 264 ms
51,616 KB
testcase_39 AC 251 ms
51,552 KB
testcase_40 AC 266 ms
51,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:8:13: warning: 'appendln(Any?): 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(
            ^

ソースコード

diff #

fun main() {
    val builder = StringBuilder()

    val n = readInputLine().toInt()

    val arr = readInputLine().split(" ").map { it.toInt() }.sorted().toIntArray()

    builder.appendln(
        if (n % 2 == 1) {
            arr[n / 2]
        } else {
            (arr[n / 2 - 1] + arr[n / 2]).toDouble() / 2.0
        }
    )

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0