結果

問題 No.39 桁の数字を入れ替え
ユーザー zeroyonichihachizeroyonichihachi
提出日時 2016-10-24 13:41:35
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 168 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 15,312 KB
最終ジャッジ日時 2023-08-15 18:35:05
合計ジャッジ時間 3,074 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,308 KB
testcase_01 AC 85 ms
15,132 KB
testcase_02 AC 80 ms
15,276 KB
testcase_03 AC 79 ms
15,132 KB
testcase_04 AC 80 ms
15,024 KB
testcase_05 AC 85 ms
15,076 KB
testcase_06 AC 79 ms
15,284 KB
testcase_07 AC 80 ms
15,036 KB
testcase_08 WA -
testcase_09 AC 80 ms
15,112 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 80 ms
15,132 KB
testcase_15 AC 81 ms
15,280 KB
testcase_16 AC 81 ms
15,288 KB
testcase_17 AC 81 ms
15,024 KB
testcase_18 AC 81 ms
15,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.chars
m = n.max_by(&:to_i)
i = n.size - n.reverse.index(m) - 1
j = n.find_index{|c| m.to_i > c.to_i  }
n[i], n[j] = n[j], n[i] unless j.nil?
puts n.join
0