結果

問題 No.927 Second Permutation
ユーザー 💕💖💞💕💖💞
提出日時 2019-12-23 21:55:25
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 716 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 14,502 ms
コンパイル使用メモリ 441,412 KB
実行使用メモリ 61,348 KB
最終ジャッジ日時 2023-10-19 05:29:50
合計ジャッジ時間 32,644 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 337 ms
58,576 KB
testcase_01 AC 338 ms
58,572 KB
testcase_02 AC 338 ms
58,576 KB
testcase_03 AC 335 ms
58,576 KB
testcase_04 AC 333 ms
58,576 KB
testcase_05 AC 331 ms
58,584 KB
testcase_06 AC 334 ms
58,572 KB
testcase_07 AC 336 ms
58,580 KB
testcase_08 AC 587 ms
60,144 KB
testcase_09 AC 369 ms
58,796 KB
testcase_10 AC 625 ms
60,788 KB
testcase_11 AC 694 ms
61,120 KB
testcase_12 AC 612 ms
60,984 KB
testcase_13 AC 443 ms
58,964 KB
testcase_14 AC 637 ms
60,268 KB
testcase_15 AC 604 ms
60,532 KB
testcase_16 AC 713 ms
60,720 KB
testcase_17 AC 707 ms
60,560 KB
testcase_18 AC 695 ms
61,348 KB
testcase_19 AC 697 ms
60,640 KB
testcase_20 AC 716 ms
61,144 KB
testcase_21 AC 710 ms
60,768 KB
testcase_22 AC 707 ms
61,124 KB
testcase_23 AC 700 ms
60,544 KB
testcase_24 AC 480 ms
59,060 KB
testcase_25 AC 457 ms
59,024 KB
testcase_26 AC 439 ms
58,904 KB
testcase_27 AC 431 ms
58,888 KB
testcase_28 AC 493 ms
59,044 KB
testcase_29 AC 460 ms
59,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^

ソースコード

diff #

fun main(args:Array<String>) {
    val a = readLine()!!
    val b = a.toList().sorted().reversed().map { it.toString().toInt() }.toMutableList()

    //println(a)
    //println(b)
    val last = b.last()
    var good = false
    for(i in b.size-1 downTo 0 step 1) {
        //println(b[i])
        if( last != b[i]) {
            good = true
            b[i+1] = b[i]
            b[i] = last
            break
        }
    }
    if(good == false) {
        println(-1)
    } else if(b.first() == 0) {
        println(-1)
    } else {
        println(b.map{it.toString()}.joinToString(""))
    }
}
0