結果
問題 | No.39 桁の数字を入れ替え |
ユーザー | masumasumath1 |
提出日時 | 2019-12-08 11:29:38 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 468 bytes |
コンパイル時間 | 93 ms |
コンパイル使用メモリ | 10,812 KB |
実行使用メモリ | 8,212 KB |
最終ジャッジ日時 | 2023-08-28 17:10:02 |
合計ジャッジ時間 | 1,300 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
8,188 KB |
testcase_01 | AC | 14 ms
7,760 KB |
testcase_02 | AC | 14 ms
8,104 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 15 ms
7,952 KB |
testcase_08 | AC | 15 ms
8,064 KB |
testcase_09 | AC | 14 ms
8,212 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 14 ms
7,768 KB |
testcase_15 | AC | 14 ms
7,840 KB |
testcase_16 | AC | 14 ms
7,924 KB |
testcase_17 | AC | 14 ms
7,832 KB |
testcase_18 | AC | 14 ms
7,816 KB |
ソースコード
N = int(input()) listN = list(str(N)) first = listN[0] for i in range(1,len(listN)): flg = True second = listN[i] if first < second: flg = False break first = second if flg: print(N) exit() maxs = [i for i,x in enumerate(listN) if x == max(listN)] id1 = maxs[0] id2 = maxs[-1] if len(maxs) > 1 and (id1 == id2 or id1 == 0): print(N) else: listN[0],listN[id2] = listN[id2],listN[0] print(int("".join(map(str,listN))))