結果

問題 No.927 Second Permutation
ユーザー Omura ShunsukeOmura Shunsuke
提出日時 2020-05-01 09:18:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 272 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 87,384 KB
最終ジャッジ日時 2023-08-24 22:54:42
合計ジャッジ時間 5,252 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,404 KB
testcase_01 AC 87 ms
71,156 KB
testcase_02 AC 93 ms
71,172 KB
testcase_03 AC 87 ms
71,384 KB
testcase_04 AC 87 ms
71,380 KB
testcase_05 AC 87 ms
71,060 KB
testcase_06 AC 85 ms
71,332 KB
testcase_07 AC 88 ms
71,280 KB
testcase_08 AC 115 ms
79,664 KB
testcase_09 AC 92 ms
75,808 KB
testcase_10 AC 117 ms
81,860 KB
testcase_11 AC 131 ms
85,796 KB
testcase_12 AC 115 ms
81,340 KB
testcase_13 AC 94 ms
75,900 KB
testcase_14 AC 117 ms
82,292 KB
testcase_15 AC 110 ms
81,164 KB
testcase_16 AC 136 ms
87,136 KB
testcase_17 AC 134 ms
87,084 KB
testcase_18 AC 135 ms
87,036 KB
testcase_19 AC 135 ms
87,384 KB
testcase_20 AC 137 ms
87,016 KB
testcase_21 AC 136 ms
87,144 KB
testcase_22 AC 134 ms
87,048 KB
testcase_23 AC 136 ms
87,360 KB
testcase_24 AC 112 ms
86,876 KB
testcase_25 AC 109 ms
83,168 KB
testcase_26 AC 105 ms
81,336 KB
testcase_27 AC 99 ms
78,200 KB
testcase_28 AC 111 ms
85,656 KB
testcase_29 AC 109 ms
84,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=list(input())
S.sort(reverse=True)

import copy
s=copy.deepcopy(S)

for i in range(1,len(S)):
    if s[-1-(i-1)] != s[-1-i]:
        s[-1-(i-1)],s[-1-i] = s[-1-i],s[-1-(i-1)]
        break
if s[0]=="0":
    print(-1)
elif S!=s:
    print("".join(s))
else:
    print(-1)
0