結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー 箱星
提出日時 2021-08-11 08:58:08
言語 Kotlin
(2.1.0)
結果
WA  
実行時間 -
コード長 1,485 bytes
コンパイル時間 12,808 ms
コンパイル使用メモリ 442,652 KB
実行使用メモリ 117,816 KB
最終ジャッジ日時 2024-10-07 08:51:46
合計ジャッジ時間 50,474 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:19:11: warning: variable 'v' is never used
    for ((v, i, is_a) in lst) {
          ^

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val n = nextInt()
    val k = nextInt()
    val a = Array(n) { nextInt() }
    val b = Array(n) { nextInt() }
    val lst = mutableListOf<Triple<Int, Int, Boolean>>()
    for (i in 0 until n) {
        lst.add(Triple(a[i], i, true))
        lst.add(Triple(b[i], i, false))
    }
    lst.sortByDescending { it.first }
    val choice = CharArray(n) { '.' }
    var a_rem = k
    var b_rem = n - k
    for ((v, i, is_a) in lst) {
        if (a_rem == 0 || b_rem == 0) break
        if (is_a && choice[i] == '.') {
            choice[i] = 'A'
            a_rem--
        } else if (!is_a && choice[i] == '.') {
            choice[i] = 'B'
            b_rem--
        }
    }
    for (i in 0 until n) {
        if (choice[i] == '.') {
            if (a_rem == 0) choice[i] = 'B'
            else choice[i] = '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
0