結果

問題 No.39 桁の数字を入れ替え
ユーザー ABKZ
提出日時 2021-12-12 01:19:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,096 KB
最終ジャッジ日時 2024-07-20 09:47:21
合計ジャッジ時間 1,551 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

N = list(map(int, list(input())))

for n in reversed(range(1, 10)):
    positions_n = [p for p,v in enumerate(N) if v == n]
    if len(positions_n) > 0:
        n_pos = max(positions_n)
        for j in range(n_pos):
            if N[j] < N[n_pos]:
                N[j],N[n_pos] = N[n_pos],N[j]
                break
        else:
            continue
        break

print("".join(map(str, N)))
0