結果

問題 No.39 桁の数字を入れ替え
ユーザー human_cipherhuman_cipher
提出日時 2021-06-22 01:46:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 288 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 10,636 KB
実行使用メモリ 8,500 KB
最終ジャッジ日時 2023-09-05 02:09:20
合計ジャッジ時間 2,354 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,500 KB
testcase_01 AC 18 ms
8,304 KB
testcase_02 AC 18 ms
8,308 KB
testcase_03 AC 18 ms
8,468 KB
testcase_04 AC 19 ms
8,464 KB
testcase_05 AC 18 ms
8,372 KB
testcase_06 AC 18 ms
8,288 KB
testcase_07 AC 19 ms
8,336 KB
testcase_08 AC 19 ms
8,312 KB
testcase_09 AC 19 ms
8,304 KB
testcase_10 AC 19 ms
8,308 KB
testcase_11 AC 18 ms
8,392 KB
testcase_12 AC 19 ms
8,308 KB
testcase_13 AC 18 ms
8,468 KB
testcase_14 AC 18 ms
8,308 KB
testcase_15 AC 19 ms
8,432 KB
testcase_16 AC 18 ms
8,460 KB
testcase_17 AC 19 ms
8,488 KB
testcase_18 AC 19 ms
8,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import copy

n = list(str(int(input())))

ans = int("".join(n))
for i in range(len(n)):
    for j in range(i+1,len(n)):
        if int(n[i]) < int(n[j]):
            tmp = copy(n)
            tmp[i],tmp[j] = tmp[j],tmp[i]
            ans = max(ans,int("".join(tmp)))
print(ans)
0