結果

問題 No.927 Second Permutation
ユーザー ch1channnch1channn
提出日時 2023-01-27 01:19:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 79,404 KB
最終ジャッジ日時 2023-09-09 22:37:54
合計ジャッジ時間 6,234 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,920 KB
testcase_01 AC 71 ms
71,072 KB
testcase_02 AC 71 ms
71,412 KB
testcase_03 AC 70 ms
71,416 KB
testcase_04 AC 69 ms
71,320 KB
testcase_05 AC 71 ms
71,312 KB
testcase_06 AC 71 ms
71,172 KB
testcase_07 AC 74 ms
71,056 KB
testcase_08 AC 89 ms
76,628 KB
testcase_09 AC 72 ms
71,352 KB
testcase_10 AC 90 ms
77,508 KB
testcase_11 AC 99 ms
79,296 KB
testcase_12 AC 86 ms
77,136 KB
testcase_13 AC 71 ms
71,196 KB
testcase_14 AC 88 ms
77,844 KB
testcase_15 AC 85 ms
77,212 KB
testcase_16 AC 101 ms
79,364 KB
testcase_17 AC 104 ms
79,340 KB
testcase_18 AC 103 ms
79,376 KB
testcase_19 AC 106 ms
79,404 KB
testcase_20 AC 108 ms
79,396 KB
testcase_21 AC 107 ms
79,324 KB
testcase_22 AC 108 ms
79,216 KB
testcase_23 AC 106 ms
79,216 KB
testcase_24 AC 84 ms
78,708 KB
testcase_25 AC 83 ms
77,480 KB
testcase_26 AC 86 ms
77,140 KB
testcase_27 AC 83 ms
76,936 KB
testcase_28 AC 87 ms
78,564 KB
testcase_29 AC 81 ms
77,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
if sys.platform =='ios':
	import clipboard
	a=clipboard.get()
	a = a.split('\n')
	text = '\n'.join(a)
	with open('input_file.txt','w') as f:
		f.write(text)
	sys.stdin = open('input_file.txt')
sys.setrecursionlimit(4100000)
stdin = sys.stdin 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()
nm = lambda: map(int,input().split())

X = list(input())
x = sorted(X)[::-1]
cnt = 0
for i in range(len(X)-1,0,-1):

	if x[i-1] > x[i]:
		x[i-1],x[i] = x[i],x[i-1]
		break
	cnt += 1 


if x[0] == "0":
	print(-1)
	exit()
if cnt == len(X)-1:
	print(-1)
else:
	print("".join(x))
	
0