結果

問題 No.927 Second Permutation
ユーザー tamatotamato
提出日時 2019-11-22 21:29:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 336 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 75,996 KB
最終ジャッジ日時 2024-04-19 10:32:39
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,604 KB
testcase_01 AC 34 ms
54,228 KB
testcase_02 AC 35 ms
54,540 KB
testcase_03 AC 35 ms
54,292 KB
testcase_04 AC 35 ms
53,960 KB
testcase_05 AC 35 ms
54,748 KB
testcase_06 AC 35 ms
54,132 KB
testcase_07 AC 34 ms
54,876 KB
testcase_08 AC 50 ms
67,448 KB
testcase_09 AC 40 ms
60,720 KB
testcase_10 AC 59 ms
69,412 KB
testcase_11 AC 68 ms
74,776 KB
testcase_12 AC 52 ms
67,264 KB
testcase_13 AC 40 ms
61,984 KB
testcase_14 AC 60 ms
70,304 KB
testcase_15 AC 53 ms
68,384 KB
testcase_16 AC 72 ms
75,456 KB
testcase_17 AC 72 ms
75,996 KB
testcase_18 AC 70 ms
75,208 KB
testcase_19 AC 71 ms
75,196 KB
testcase_20 AC 72 ms
75,616 KB
testcase_21 AC 70 ms
75,992 KB
testcase_22 AC 70 ms
75,248 KB
testcase_23 AC 71 ms
75,272 KB
testcase_24 AC 43 ms
67,520 KB
testcase_25 AC 42 ms
65,812 KB
testcase_26 AC 41 ms
64,504 KB
testcase_27 AC 42 ms
65,544 KB
testcase_28 AC 48 ms
72,128 KB
testcase_29 AC 47 ms
70,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

x = input()
c = Counter(x)

if len(c.keys()) == 1:
    print(-1)
    exit()

ans = sorted(x, reverse=True)
for i in range(len(ans)-1, -1, -1):
    if ans[i] != ans[i-1]:
        ans[i], ans[i-1] = ans[i-1], ans[i]
        break

if ans[0] == '0':
    print(-1)
    exit()

print(''.join(map(str, ans)))
0