結果

問題 No.927 Second Permutation
ユーザー shamio
提出日時 2020-06-02 17:12:06
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 253 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,412 KB
最終ジャッジ日時 2024-11-24 04:06:18
合計ジャッジ時間 2,912 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

x = list(map(int, input()))
l = len(x)

x.sort(reverse=True)
for i in range(l - 1, 0, -1):
    if x[i] != x[i-1]:
        x[i], x[i-1] = x[i-1], x[i]
        break

else:
    print(-1)
    exit()

if x[0] == 0:
    print(-1)
else:
    print(*x, sep="")
0