結果

問題 No.927 Second Permutation
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-07 03:28:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 211 bytes
コンパイル時間 63 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 25,364 KB
最終ジャッジ日時 2023-09-18 12:18:19
合計ジャッジ時間 4,965 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,276 KB
testcase_01 AC 78 ms
15,144 KB
testcase_02 AC 79 ms
15,144 KB
testcase_03 AC 79 ms
15,168 KB
testcase_04 AC 80 ms
15,084 KB
testcase_05 AC 83 ms
15,072 KB
testcase_06 AC 79 ms
15,260 KB
testcase_07 AC 79 ms
15,224 KB
testcase_08 AC 110 ms
18,104 KB
testcase_09 AC 83 ms
15,056 KB
testcase_10 AC 126 ms
20,552 KB
testcase_11 AC 156 ms
21,976 KB
testcase_12 AC 116 ms
18,952 KB
testcase_13 AC 84 ms
15,552 KB
testcase_14 AC 126 ms
20,584 KB
testcase_15 AC 114 ms
19,020 KB
testcase_16 AC 170 ms
25,148 KB
testcase_17 AC 167 ms
25,364 KB
testcase_18 AC 167 ms
25,188 KB
testcase_19 AC 165 ms
25,164 KB
testcase_20 AC 166 ms
25,168 KB
testcase_21 AC 169 ms
25,284 KB
testcase_22 AC 166 ms
25,164 KB
testcase_23 AC 168 ms
25,320 KB
testcase_24 AC 129 ms
22,336 KB
testcase_25 AC 108 ms
19,804 KB
testcase_26 AC 100 ms
18,656 KB
testcase_27 AC 97 ms
17,824 KB
testcase_28 AC 124 ms
21,980 KB
testcase_29 AC 114 ms
20,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s=gets.chomp.split("").map{|e| e.to_i}.sort.reverse
s2=s.size-1
ans=-1
ok=false
s2.downto(1){|i|
	j=i-1
	if s[i]!=s[j] then
		s[i],s[j]=s[j],s[i]
		ok=true
		break
	end
}
ans=s.join("") if ok && s[0]!=0
puts ans
0