結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
|
提出日時 | 2020-03-23 11:39:17 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 113 ms / 5,000 ms |
コード長 | 427 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-12-26 05:53:51 |
合計ジャッジ時間 | 3,757 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
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