結果
問題 | No.1650 Moving Coins |
ユーザー |
|
提出日時 | 2021-11-01 13:33:21 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 641 ms / 2,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 61,952 KB |
最終ジャッジ日時 | 2024-10-10 01:53:56 |
合計ジャッジ時間 | 16,011 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i A = gets.split(" ").map{|s| s.to_i} B = gets.split(" ").map{|s| s.to_i} q = [] c = Array.new((A+B).max, false) 0.upto(N-1) {|i| a, b = A[i], B[i] c[a-1] = true if a < b then q.unshift([i+1, a, b]) else q << [i+1, a, b] end } ans = [] while q.length > 0 do i, from, to = q.shift d = from < to ? 1 : -1 while from != to do ans << [i, d > 0 ? "R" : "L"] from += d end end puts ans.length ans.each {|i, d| puts "#{i} #{d}" }