結果
問題 | No.39 桁の数字を入れ替え |
ユーザー | gemmaro |
提出日時 | 2020-03-23 11:39:17 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 85 ms / 5,000 ms |
コード長 | 427 bytes |
コンパイル時間 | 578 ms |
コンパイル使用メモリ | 11,316 KB |
実行使用メモリ | 15,348 KB |
最終ジャッジ日時 | 2023-08-27 01:24:49 |
合計ジャッジ時間 | 3,567 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
15,196 KB |
testcase_01 | AC | 84 ms
15,240 KB |
testcase_02 | AC | 84 ms
15,252 KB |
testcase_03 | AC | 85 ms
15,060 KB |
testcase_04 | AC | 85 ms
15,292 KB |
testcase_05 | AC | 83 ms
15,004 KB |
testcase_06 | AC | 83 ms
15,124 KB |
testcase_07 | AC | 83 ms
15,112 KB |
testcase_08 | AC | 84 ms
15,348 KB |
testcase_09 | AC | 84 ms
15,188 KB |
testcase_10 | AC | 84 ms
15,280 KB |
testcase_11 | AC | 83 ms
15,132 KB |
testcase_12 | AC | 84 ms
15,136 KB |
testcase_13 | AC | 83 ms
15,232 KB |
testcase_14 | AC | 81 ms
15,128 KB |
testcase_15 | AC | 83 ms
15,236 KB |
testcase_16 | AC | 82 ms
15,132 KB |
testcase_17 | AC | 83 ms
15,196 KB |
testcase_18 | AC | 82 ms
15,140 KB |
コンパイルメッセージ
Syntax OK
ソースコード
# frozen_string_literal: true N = gets.chomp.chars.map(&:to_i) result = N (0..N.size - 2).each do |index| rights = index + 1..N.size - 1 right_max = N[rights].max next unless N[index] < right_max rights.to_a.reverse.each do |right_index| next unless N[right_index] == right_max result[index], result[right_index] = result[right_index], result[index] puts result.join exit end end puts result.join