結果

問題 No.39 桁の数字を入れ替え
ユーザー ABKZABKZ
提出日時 2021-12-12 01:19:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 395 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 71,648 KB
最終ジャッジ日時 2023-09-27 15:37:25
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,168 KB
testcase_01 AC 60 ms
71,648 KB
testcase_02 AC 63 ms
71,308 KB
testcase_03 AC 63 ms
71,368 KB
testcase_04 AC 61 ms
71,376 KB
testcase_05 AC 61 ms
71,304 KB
testcase_06 AC 60 ms
71,480 KB
testcase_07 AC 61 ms
71,116 KB
testcase_08 AC 60 ms
71,168 KB
testcase_09 AC 61 ms
71,472 KB
testcase_10 AC 62 ms
71,404 KB
testcase_11 AC 62 ms
71,340 KB
testcase_12 AC 59 ms
71,296 KB
testcase_13 AC 59 ms
71,420 KB
testcase_14 AC 60 ms
71,436 KB
testcase_15 AC 60 ms
71,340 KB
testcase_16 AC 60 ms
71,376 KB
testcase_17 AC 61 ms
71,528 KB
testcase_18 AC 61 ms
71,432 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