結果

問題 No.39 桁の数字を入れ替え
ユーザー ABKZ
提出日時 2021-12-12 01:04:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 383 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,932 KB
実行使用メモリ 53,720 KB
最終ジャッジ日時 2024-07-20 09:00:52
合計ジャッジ時間 1,786 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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