結果

問題 No.927 Second Permutation
ユーザー brthyyjpbrthyyjp
提出日時 2020-04-14 10:00:34
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 409 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 67,160 KB
最終ジャッジ日時 2024-10-01 16:51:30
合計ジャッジ時間 3,664 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 1 RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

x = int(input())
s = list(str(x))

if len(set(s)) == 1:
    print(-1)
    exit()

s = [int(i) for i in s]
s.sort(reverse=True)

if len(s) == 2:
    ans =  str(s[1])+str(s[0])
    if s[1] == 0:
        print(-1)
        exit()
    else:
        print(ans)
        exit()

ans = str(s[0])+str(s[2])
for i in range(len(s)):
    if i == 0 or i == 2:
        continue
    else:
        ans += str(s[i])
print(ans)
0