結果
問題 |
No.1282 Display Elements
|
ユーザー |
![]() |
提出日時 | 2020-11-07 22:14:43 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 1,434 ms / 2,000 ms |
コード長 | 735 bytes |
コンパイル時間 | 14,382 ms |
コンパイル使用メモリ | 442,564 KB |
実行使用メモリ | 101,760 KB |
最終ジャッジ日時 | 2024-07-22 14:52:41 |
合計ジャッジ時間 | 32,951 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
コンパイルメッセージ
Main.kt:19:13: warning: 'appendln(Long): 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(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() }