結果

問題 No.39 桁の数字を入れ替え
ユーザー バカらっくバカらっく
提出日時 2021-11-10 09:49:58
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 297 ms / 5,000 ms
コード長 447 bytes
コンパイル時間 10,201 ms
コンパイル使用メモリ 433,672 KB
実行使用メモリ 60,348 KB
最終ジャッジ日時 2024-04-30 20:37:29
合計ジャッジ時間 16,664 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
60,128 KB
testcase_01 AC 274 ms
60,256 KB
testcase_02 AC 284 ms
60,296 KB
testcase_03 AC 281 ms
60,324 KB
testcase_04 AC 297 ms
60,144 KB
testcase_05 AC 290 ms
60,284 KB
testcase_06 AC 289 ms
60,344 KB
testcase_07 AC 284 ms
60,152 KB
testcase_08 AC 285 ms
60,188 KB
testcase_09 AC 290 ms
60,172 KB
testcase_10 AC 281 ms
60,252 KB
testcase_11 AC 285 ms
60,316 KB
testcase_12 AC 296 ms
60,344 KB
testcase_13 AC 288 ms
60,256 KB
testcase_14 AC 280 ms
60,184 KB
testcase_15 AC 285 ms
60,264 KB
testcase_16 AC 284 ms
60,280 KB
testcase_17 AC 288 ms
60,348 KB
testcase_18 AC 286 ms
60,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

fun main(args: Array<String>) {
    val n = readLine()!!.map { it.toString().toInt() }.toMutableList()
    val a = mutableListOf<MutableList<Int>>().also { it.add(n) }
    for(i in (0 until n.lastIndex)) {
        for(j in (1 .. n.lastIndex)) {
            val tmp = n.toMutableList()
            tmp[i] = n[j]
            tmp[j] = n[i]
            a.add(tmp)
        }
    }
    println(a.map { it.joinToString("") }.sortedDescending().first())
}
0