結果

問題 No.39 桁の数字を入れ替え
ユーザー sekihankamibanz
提出日時 2018-10-27 19:07:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-19 06:50:08
合計ジャッジ時間 1,423 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

n = [x for x in input()]

max_num = max(n)
max_num_index = [x for x, i in enumerate(n) if i == max_num].pop()
for x, i in enumerate(n):
    if all(n) == max_num:
        break
    if i != max_num:
        replace_num = i
        replace_index = x
        if replace_index < max_num_index:
            n[max_num_index] = n[replace_index]
            n[replace_index] = max_num
            break
print(int(''.join(n)))
   
0