結果

問題 No.39 桁の数字を入れ替え
ユーザー ABKZABKZ
提出日時 2021-12-12 01:04:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 383 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 71,464 KB
最終ジャッジ日時 2023-09-27 14:56:45
合計ジャッジ時間 2,804 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,124 KB
testcase_01 AC 65 ms
71,016 KB
testcase_02 AC 63 ms
71,212 KB
testcase_03 AC 67 ms
71,016 KB
testcase_04 AC 64 ms
71,208 KB
testcase_05 AC 65 ms
71,120 KB
testcase_06 AC 63 ms
71,120 KB
testcase_07 AC 65 ms
70,900 KB
testcase_08 AC 63 ms
71,020 KB
testcase_09 AC 63 ms
71,032 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 63 ms
71,112 KB
testcase_15 AC 65 ms
71,204 KB
testcase_16 AC 62 ms
71,292 KB
testcase_17 AC 61 ms
71,112 KB
testcase_18 AC 65 ms
71,276 KB
権限があれば一括ダウンロードができます

ソースコード

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