結果
| 問題 | No.927 Second Permutation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-10 18:57:23 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 107 ms / 2,000 ms |
| コード長 | 265 bytes |
| 記録 | |
| コンパイル時間 | 336 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 16,604 KB |
| 最終ジャッジ日時 | 2026-04-17 06:33:23 |
| 合計ジャッジ時間 | 4,420 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
ans = sorted(list(input()), reverse=True)
x = len(ans) - ans.count(ans[-1])
l = 0 if ans[-1] == '0' else -1
r = x - 1
for i in range(r, l, -1):
if ans[i] > ans[x]:
ans[i], ans[x] = ans[x], ans[i]
break
else:
ans = ["-1"]
print(''.join(ans))