結果
| 問題 | No.1282 Display Elements |
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-11-07 22:14:43 |
| 言語 | Kotlin (2.3.20) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 735 bytes |
| 記録 | |
| コンパイル時間 | 6,738 ms |
| コンパイル使用メモリ | 446,384 KB |
| 最終ジャッジ日時 | 2026-04-03 09:35:43 |
| 合計ジャッジ時間 | 7,198 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Main.kt:19:13: error: 'fun StringBuilder.appendln(value: Long): 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()
readInputLine()
val aList = readInputLine().split(" ").map { it.toInt() }.sorted()
val bArr = readInputLine().split(" ").map { it.toInt() }.toIntArray()
val bListSorted = mutableListOf<Int>()
var ans = 0L
for ((i, a) in aList.withIndex()) {
bListSorted.add(lowerBound(bListSorted, bArr[i]), bArr[i])
ans += lowerBound(bListSorted, a).toLong()
}
builder.appendln(ans)
print(builder.toString())
}
fun readInputLine(): String {
return readLine()!!
}
fun <T: Comparable<T>> lowerBound(list: List<T>, value: T): Int {
return Collections.binarySearch(list, value, { x, y -> if (x >= y) 1 else -1}).inv()
}
rutilicus