結果

問題 No.927 Second Permutation
ユーザー akanayaakanaya
提出日時 2020-03-29 16:05:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 9,292 KB
最終ジャッジ日時 2023-08-30 19:05:06
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,408 KB
testcase_01 AC 18 ms
8,464 KB
testcase_02 AC 18 ms
8,432 KB
testcase_03 AC 18 ms
8,492 KB
testcase_04 AC 18 ms
8,392 KB
testcase_05 AC 17 ms
8,404 KB
testcase_06 AC 18 ms
8,360 KB
testcase_07 AC 18 ms
8,392 KB
testcase_08 AC 21 ms
8,672 KB
testcase_09 AC 18 ms
8,448 KB
testcase_10 AC 23 ms
8,740 KB
testcase_11 AC 27 ms
9,100 KB
testcase_12 AC 22 ms
8,716 KB
testcase_13 AC 18 ms
8,380 KB
testcase_14 AC 23 ms
8,876 KB
testcase_15 AC 22 ms
8,788 KB
testcase_16 AC 27 ms
9,192 KB
testcase_17 AC 28 ms
9,192 KB
testcase_18 AC 27 ms
9,272 KB
testcase_19 AC 27 ms
9,204 KB
testcase_20 AC 27 ms
9,276 KB
testcase_21 AC 28 ms
9,240 KB
testcase_22 AC 28 ms
9,172 KB
testcase_23 AC 28 ms
9,196 KB
testcase_24 AC 27 ms
9,292 KB
testcase_25 AC 24 ms
8,952 KB
testcase_26 AC 22 ms
8,768 KB
testcase_27 AC 21 ms
8,592 KB
testcase_28 AC 26 ms
9,200 KB
testcase_29 AC 24 ms
9,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

x = list(input().strip())

c = Counter(x)

if len(c.keys()) == 1:
    print(-1)
elif c['0'] == len(x) - 1:
    print(-1)
else:
    v = sorted(c.keys())[0]
    c[v] -= 1

    e = sorted(c.keys(), reverse=True)
    for i in range(len(e)):
        t = str(e[i])
        if i != len(e) - 2:
            print(t * c[t], end='')
        else:
            print(t * (c[t] - 1), end='')
            print(v, end='')
            print(t, end='')
    print()            




    

0