結果

問題 No.1280 Beyond C
ユーザー rutilicusrutilicus
提出日時 2020-11-07 21:21:19
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 839 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 11,914 ms
コンパイル使用メモリ 452,200 KB
実行使用メモリ 93,240 KB
最終ジャッジ日時 2024-07-22 14:50:20
合計ジャッジ時間 23,499 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:17:13: warning: 'appendln(Double): 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(cnt.toDouble() / (n * m).toDouble())
            ^

ソースコード

diff #

import java.util.*

fun main() {
    val builder = StringBuilder()

    val (n, m, c) = readInputLine().split(" ").map { it.toLong() }

    val aList = readInputLine().split(" ").map { it.toLong() }
    val bList = readInputLine().split(" ").map { it.toLong() }.sorted()

    var cnt = 0L

    for (a in aList) {
        cnt += m - upperBound(bList, c / a).toLong()
    }

    builder.appendln(cnt.toDouble() / (n * m).toDouble())

    print(builder.toString())
}

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

fun <T: Comparable<T>> upperBound(list: List<T>, value: T): Int {
    return Collections.binarySearch(list, value, {x, y -> if (x > y) 1 else -1}).inv()
}
0