結果

問題 No.39 桁の数字を入れ替え
ユーザー tnoda_
提出日時 2015-08-01 17:24:07
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 351 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-02 06:34:22
合計ジャッジ時間 941 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def to_int(ds):
    res = 0
    for d in ds:
        res *= 10
        res += d
    return res


def swap(ds, i, j):
    ds2 = ds[:]
    x = ds2[i]
    y = ds2[j]
    ds2[i] = y
    ds2[j] = x
    return ds2

ds = [int(x) for x in raw_input()]
L = len(ds)

ans = max([to_int(swap(ds, i, j))
           for i in range(L) for j in range(L)])
print(ans)
0