結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー rutilicus
提出日時 2020-08-30 21:19:29
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 421 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,505 ms
コンパイル使用メモリ 435,024 KB
最終ジャッジ日時 2026-05-10 13:05:02
合計ジャッジ時間 7,223 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.kt:8:13: error: 'fun StringBuilder.appendln(value: Any?): 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 #
raw source code

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