結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
Konton7
|
| 提出日時 | 2019-11-22 21:34:50 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 2,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 122 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,904 KB |
| 最終ジャッジ日時 | 2024-10-11 02:57:00 |
| 合計ジャッジ時間 | 2,610 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
s = input()
counter = [0 for i in range(10)]
for i in s:
counter[int(i)] += 1
l = len(s)
ans = -1
if counter[0] < l-1 and max(counter) != l:
ans = 0
first = []
for i in range(9,-1,-1):
first += [str(i)] * counter[i]
lf = len(first)
for i in range(lf-2, -1, -1):
if first[i] != first[i+1]:
first[i], first[i+1] = first[i+1], first[i]
break
ans = "".join(first)
print(ans)
Konton7