結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
tanukidon
|
| 提出日時 | 2018-03-24 11:29:19 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 284 bytes |
| コンパイル時間 | 59 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-06-25 02:44:46 |
| 合計ジャッジ時間 | 2,535 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 19 |
コンパイルメッセージ
Main.rb:12: warning: possibly useless use of != in void context Syntax OK
ソースコード
n = gets.chomp.split("").map(&:to_i)
a = n
b = 0
c = 0
d = 0
m = 0
n.size.times do |i|
p n
if n[0] == n.max
n = n.drop(1)
d += 1
else n[0] !=n.max
m = n.rindex(n.max) + d
c = i
b += 1
p m , c
break
end
end
a[m],a[c] =a[c],a[m] if b == 1
puts a.join
tanukidon