結果

問題 No.927 Second Permutation
ユーザー 👑 tamatotamato
提出日時 2019-11-22 21:29:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 336 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 79,736 KB
最終ジャッジ日時 2023-08-01 11:01:07
合計ジャッジ時間 4,959 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,572 KB
testcase_01 AC 95 ms
71,624 KB
testcase_02 AC 95 ms
71,644 KB
testcase_03 AC 95 ms
71,756 KB
testcase_04 AC 96 ms
71,780 KB
testcase_05 AC 97 ms
71,780 KB
testcase_06 AC 95 ms
71,764 KB
testcase_07 AC 95 ms
71,480 KB
testcase_08 AC 112 ms
78,004 KB
testcase_09 AC 99 ms
77,100 KB
testcase_10 AC 118 ms
78,372 KB
testcase_11 AC 128 ms
79,212 KB
testcase_12 AC 112 ms
78,284 KB
testcase_13 AC 101 ms
77,480 KB
testcase_14 AC 118 ms
78,580 KB
testcase_15 AC 115 ms
77,976 KB
testcase_16 AC 131 ms
79,736 KB
testcase_17 AC 131 ms
79,700 KB
testcase_18 AC 133 ms
79,704 KB
testcase_19 AC 133 ms
79,564 KB
testcase_20 AC 132 ms
79,256 KB
testcase_21 AC 131 ms
79,580 KB
testcase_22 AC 132 ms
79,516 KB
testcase_23 AC 132 ms
79,256 KB
testcase_24 AC 102 ms
76,552 KB
testcase_25 AC 102 ms
76,820 KB
testcase_26 AC 102 ms
76,896 KB
testcase_27 AC 106 ms
77,664 KB
testcase_28 AC 109 ms
78,260 KB
testcase_29 AC 108 ms
78,256 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