結果

問題 No.927 Second Permutation
ユーザー ttr
提出日時 2020-02-04 18:29:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 362 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-09-21 07:35:45
合計ジャッジ時間 2,413 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

X = int(input())

L = []
for i in range(len(str(X))):
    L.append(str(X)[i])
L.sort(reverse=True)
if L[0] == L[-1]:
    print(-1)
else:
    for i in range(len(L)-1, 0, -1):
        if L[i] != L[i-1]:
            t = L[i]
            L[i] = L[i-1]
            L[i-1] = t
            break
    if L[0] != "0":
        print("".join(L))
    else:
        print(-1)
0