結果

問題 No.927 Second Permutation
ユーザー convexineqconvexineq
提出日時 2021-02-13 20:50:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 86,580 KB
実行使用メモリ 80,864 KB
最終ジャッジ日時 2023-09-28 06:14:28
合計ジャッジ時間 5,024 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,196 KB
testcase_01 AC 66 ms
71,012 KB
testcase_02 AC 67 ms
71,220 KB
testcase_03 AC 67 ms
71,432 KB
testcase_04 AC 67 ms
71,228 KB
testcase_05 AC 71 ms
71,424 KB
testcase_06 AC 67 ms
71,352 KB
testcase_07 AC 67 ms
71,404 KB
testcase_08 AC 97 ms
77,592 KB
testcase_09 AC 72 ms
76,348 KB
testcase_10 AC 77 ms
78,508 KB
testcase_11 AC 78 ms
80,200 KB
testcase_12 AC 75 ms
77,976 KB
testcase_13 AC 73 ms
76,392 KB
testcase_14 AC 75 ms
78,636 KB
testcase_15 AC 75 ms
77,812 KB
testcase_16 AC 78 ms
80,688 KB
testcase_17 AC 79 ms
80,644 KB
testcase_18 AC 80 ms
80,532 KB
testcase_19 AC 78 ms
80,860 KB
testcase_20 AC 80 ms
80,864 KB
testcase_21 AC 79 ms
80,860 KB
testcase_22 AC 79 ms
80,632 KB
testcase_23 AC 78 ms
80,716 KB
testcase_24 AC 73 ms
76,088 KB
testcase_25 AC 77 ms
75,960 KB
testcase_26 AC 70 ms
75,708 KB
testcase_27 AC 71 ms
76,148 KB
testcase_28 AC 72 ms
75,964 KB
testcase_29 AC 71 ms
76,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
a = [0]*10
for i in map(int,s):
    a[i] += 1
v = sum(a)
if v in a or a[0]==v-1:
    print(-1)
else:
    ans = []
    for i in range(10):
        ans += [i]*a[i]
    for i in range(10):
        if a[i]: break
    v = a[i]
    ans[v],ans[v-1] = ans[v-1],ans[v]
    print("".join(map(str,ans[::-1])))
0