結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー 👑 箱星箱星
提出日時 2021-08-11 08:58:08
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,485 bytes
コンパイル時間 12,401 ms
コンパイル使用メモリ 435,124 KB
実行使用メモリ 117,928 KB
最終ジャッジ日時 2024-04-16 13:35:18
合計ジャッジ時間 49,582 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 312 ms
54,276 KB
testcase_01 AC 315 ms
54,204 KB
testcase_02 WA -
testcase_03 AC 324 ms
54,392 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1,241 ms
116,880 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 305 ms
54,208 KB
testcase_37 AC 309 ms
54,272 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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