結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,128 KB
testcase_01 AC 78 ms
15,056 KB
testcase_02 AC 78 ms
15,132 KB
testcase_03 AC 78 ms
15,304 KB
testcase_04 AC 81 ms
15,020 KB
testcase_05 AC 79 ms
15,080 KB
testcase_06 AC 80 ms
15,276 KB
testcase_07 AC 79 ms
15,104 KB
testcase_08 AC 79 ms
15,216 KB
testcase_09 AC 78 ms
15,028 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 77 ms
15,136 KB
testcase_15 AC 78 ms
15,060 KB
testcase_16 AC 78 ms
15,300 KB
testcase_17 AC 77 ms
15,216 KB
testcase_18 AC 82 ms
15,112 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] if !j.nil? && j < i
puts n.join
0