結果
| 問題 |
No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-11 00:57:10 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 1,143 ms / 2,000 ms |
| コード長 | 998 bytes |
| コンパイル時間 | 12,896 ms |
| コンパイル使用メモリ | 435,564 KB |
| 実行使用メモリ | 117,980 KB |
| 最終ジャッジ日時 | 2024-10-07 08:46:16 |
| 合計ジャッジ時間 | 44,639 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 38 |
ソースコード
import java.io.PrintWriter
import java.util.*
import kotlin.math.*
fun PrintWriter.solve() {
val n = nextInt()
val k = nextInt()
val a = Array(n) { nextLong() }
val b = Array(n) { nextLong() }
val lst = mutableListOf<Pair<Long, Int>>()
for (i in 0 until n) {
lst.add(a[i] - b[i] to i)
}
lst.sortByDescending { it.first }
val choice = CharArray(n) { 'B' }
for (i in 0 until k) {
val ind = lst[i].second
choice[ind] = 'A'
}
println(choice.joinToString(""))
}
fun main() {
val writer = PrintWriter(System.out, false)
writer.solve()
writer.flush()
}
// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()
fun next(): String {
while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
return st.nextToken()
}
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion