結果
問題 | No.927 Second Permutation |
ユーザー |
👑 |
提出日時 | 2023-04-21 23:22:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 119 ms / 2,000 ms |
コード長 | 357 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 80,184 KB |
最終ジャッジ日時 | 2024-11-06 16:45:27 |
合計ジャッジ時間 | 3,782 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
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)))