結果

問題 No.927 Second Permutation
コンテスト
ユーザー rin204
提出日時 2023-04-21 23:22:41
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 357 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 209 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 84,864 KB
最終ジャッジ日時 2026-05-06 21:25:48
合計ジャッジ時間 4,689 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys


sys.set_int_max_str_digits(10 ** 9)

x = input()
lst = [i for i in x]
lst.sort(reverse = True)
if lst[0] == lst[-1] or lst[1] == "0":
    print(-1)
    exit()
l = len(lst)
for i in range(l - 1, 0, -1):
    if lst[i] == lst[i - 1]:
        continue
    else:
        lst[i], lst[i - 1] = lst[i - 1], lst[i]
        break
print(int("".join(lst)))
0