結果

問題 No.927 Second Permutation
コンテスト
ユーザー 👑 rin204
提出日時 2023-04-21 23:22:41
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 71 ms / 2,000 ms
+ 137µs
コード長 357 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 64 ms
コンパイル使用メモリ 81,984 KB
実行使用メモリ 87,772 KB
最終ジャッジ日時 2026-10-12 05:25:15
合計ジャッジ時間 3,159 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

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