結果

問題 No.927 Second Permutation
ユーザー MaboyMaboy
提出日時 2021-06-28 06:08:42
言語 Swift
(5.10.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 296 bytes
コンパイル時間 1,246 ms
コンパイル使用メモリ 121,120 KB
実行使用メモリ 14,836 KB
最終ジャッジ日時 2023-09-07 18:12:56
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,944 KB
testcase_01 AC 3 ms
8,008 KB
testcase_02 AC 3 ms
7,888 KB
testcase_03 AC 3 ms
7,964 KB
testcase_04 AC 3 ms
7,968 KB
testcase_05 AC 3 ms
7,964 KB
testcase_06 AC 3 ms
7,928 KB
testcase_07 AC 3 ms
7,972 KB
testcase_08 AC 14 ms
9,676 KB
testcase_09 AC 4 ms
7,992 KB
testcase_10 AC 22 ms
10,644 KB
testcase_11 AC 34 ms
12,172 KB
testcase_12 AC 17 ms
9,936 KB
testcase_13 AC 5 ms
8,252 KB
testcase_14 AC 24 ms
10,648 KB
testcase_15 AC 17 ms
9,956 KB
testcase_16 AC 38 ms
14,804 KB
testcase_17 AC 38 ms
14,828 KB
testcase_18 AC 37 ms
14,668 KB
testcase_19 AC 38 ms
14,756 KB
testcase_20 AC 38 ms
14,708 KB
testcase_21 AC 37 ms
14,836 KB
testcase_22 AC 37 ms
14,736 KB
testcase_23 AC 37 ms
14,764 KB
testcase_24 AC 17 ms
10,956 KB
testcase_25 AC 12 ms
10,152 KB
testcase_26 AC 10 ms
9,612 KB
testcase_27 AC 9 ms
9,116 KB
testcase_28 AC 16 ms
10,980 KB
testcase_29 AC 13 ms
10,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

var l = Array(String(readLine()!)).sorted(by: >)
var s = Set(l)
var t = l
t.removeAll(where: {$0 == "0"})
if s.count < 2 || t.count == 1{
    print(-1)
}else{
    let e = l[l.count - 1]
    let f = l.firstIndex(of: e)!
    (l[f - 1],l[f]) = (l[f],l[f - 1])
    print(l.map{String($0)}.joined())
}
0