結果

問題 No.927 Second Permutation
ユーザー r_ishidar_ishida
提出日時 2020-02-03 22:55:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 272 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 11,828 KB
実行使用メモリ 11,188 KB
最終ジャッジ日時 2023-10-19 12:47:53
合計ジャッジ時間 2,417 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,972 KB
testcase_01 AC 30 ms
9,972 KB
testcase_02 AC 30 ms
9,972 KB
testcase_03 AC 32 ms
9,972 KB
testcase_04 AC 29 ms
9,972 KB
testcase_05 AC 29 ms
9,972 KB
testcase_06 AC 29 ms
9,972 KB
testcase_07 AC 30 ms
9,972 KB
testcase_08 AC 35 ms
10,340 KB
testcase_09 AC 30 ms
9,996 KB
testcase_10 AC 38 ms
10,584 KB
testcase_11 AC 46 ms
11,156 KB
testcase_12 AC 37 ms
10,408 KB
testcase_13 AC 31 ms
10,068 KB
testcase_14 AC 40 ms
10,628 KB
testcase_15 AC 37 ms
10,400 KB
testcase_16 AC 47 ms
11,188 KB
testcase_17 AC 47 ms
11,188 KB
testcase_18 AC 47 ms
11,188 KB
testcase_19 AC 48 ms
11,188 KB
testcase_20 AC 47 ms
11,188 KB
testcase_21 AC 47 ms
11,188 KB
testcase_22 AC 48 ms
11,188 KB
testcase_23 AC 48 ms
11,188 KB
testcase_24 AC 32 ms
10,928 KB
testcase_25 AC 31 ms
10,652 KB
testcase_26 AC 31 ms
10,472 KB
testcase_27 AC 38 ms
10,100 KB
testcase_28 AC 50 ms
10,892 KB
testcase_29 AC 47 ms
10,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x = input()
y = sorted(x, reverse=True)
if y[0]==y[-1]:
    print(-1)
else:
    for i in range(1, len(y)):
        if y[-1] != y[-1-i]:
            y[-1-i], y[-i] = y[-i], y[-i-1]
            break
    if y[0] == '0':
        print(-1)
    else:
        print(''.join(y))
0