結果

問題 No.39 桁の数字を入れ替え
ユーザー バカらっくバカらっく
提出日時 2019-09-07 20:59:02
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 14,457 ms
コンパイル使用メモリ 422,020 KB
実行使用メモリ 53,192 KB
最終ジャッジ日時 2023-09-09 11:23:04
合計ジャッジ時間 21,811 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 286 ms
52,720 KB
testcase_01 AC 291 ms
52,792 KB
testcase_02 AC 282 ms
52,708 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 281 ms
52,884 KB
testcase_08 AC 282 ms
52,984 KB
testcase_09 AC 281 ms
52,804 KB
testcase_10 AC 279 ms
52,928 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 283 ms
53,060 KB
testcase_15 AC 279 ms
53,192 KB
testcase_16 AC 284 ms
52,960 KB
testcase_17 AC 286 ms
52,700 KB
testcase_18 AC 285 ms
52,956 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^
Main.kt:5:46: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Char
        val idx = inpt.lastIndexOf(inpt.max()!!)
                                             ^

ソースコード

diff #

fun main(arr:Array<String>) {
    val inpt = readLine()!!.map { it }.toMutableList()
    val ans = mutableListOf<Char>()
    (1..inpt.size).forEach {
        val idx = inpt.lastIndexOf(inpt.max()!!)
        if(idx == 0)  {
            ans.add(inpt[0])
            inpt.removeAt(0)
        } else {
            val tmp = inpt[idx]
            inpt[idx] = inpt[0]
            inpt[0] = tmp
            ans.addAll(inpt)
            println(ans.joinToString(""))
            return
        }
    }
    println(ans.joinToString(""))

}
0