結果

問題 No.927 Second Permutation
ユーザー kbyskbys
提出日時 2020-03-29 01:23:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,624 KB
実行使用メモリ 39,748 KB
最終ジャッジ日時 2023-08-30 18:24:43
合計ジャッジ時間 8,356 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
29,516 KB
testcase_01 AC 127 ms
29,708 KB
testcase_02 AC 126 ms
29,556 KB
testcase_03 AC 127 ms
29,648 KB
testcase_04 AC 128 ms
29,528 KB
testcase_05 AC 129 ms
29,612 KB
testcase_06 AC 128 ms
29,460 KB
testcase_07 AC 126 ms
29,660 KB
testcase_08 AC 146 ms
33,032 KB
testcase_09 AC 130 ms
29,808 KB
testcase_10 AC 158 ms
35,012 KB
testcase_11 AC 179 ms
39,204 KB
testcase_12 AC 151 ms
33,920 KB
testcase_13 AC 132 ms
30,324 KB
testcase_14 AC 159 ms
35,332 KB
testcase_15 AC 148 ms
33,636 KB
testcase_16 AC 185 ms
39,708 KB
testcase_17 AC 183 ms
39,472 KB
testcase_18 AC 186 ms
39,564 KB
testcase_19 AC 182 ms
39,396 KB
testcase_20 AC 183 ms
39,496 KB
testcase_21 AC 179 ms
39,748 KB
testcase_22 AC 180 ms
39,680 KB
testcase_23 AC 182 ms
39,508 KB
testcase_24 AC 146 ms
30,884 KB
testcase_25 AC 139 ms
30,376 KB
testcase_26 AC 138 ms
30,376 KB
testcase_27 AC 142 ms
30,484 KB
testcase_28 AC 158 ms
32,624 KB
testcase_29 AC 151 ms
32,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
X = list(map(int,input()))
X.sort(reverse=True)
npX = np.array(X)
mins = np.count_nonzero(npX==X[-1])
#print(npX)
#print(mins)
if X[0] == X[-1]:
    print(-1)
else:
    ans = X[:len(X)-(mins+1)]+[X[-1]]+[X[-(mins+1)]]+[X[-1]]*(mins-1)
    if ans[0] == 0:
        print(-1)
    else:
        print("".join(map(str,list(ans))))
0