結果

問題 No.1650 Moving Coins
ユーザー 小野寺健小野寺健
提出日時 2021-11-01 13:33:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 588 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 61,824 KB
最終ジャッジ日時 2024-04-18 08:38:38
合計ジャッジ時間 14,275 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,160 KB
testcase_01 AC 83 ms
20,096 KB
testcase_02 AC 85 ms
12,416 KB
testcase_03 AC 343 ms
40,576 KB
testcase_04 AC 237 ms
37,504 KB
testcase_05 AC 288 ms
40,576 KB
testcase_06 AC 339 ms
42,112 KB
testcase_07 AC 344 ms
44,160 KB
testcase_08 AC 430 ms
56,960 KB
testcase_09 AC 435 ms
60,032 KB
testcase_10 AC 464 ms
59,136 KB
testcase_11 AC 446 ms
59,904 KB
testcase_12 AC 393 ms
43,648 KB
testcase_13 AC 402 ms
49,920 KB
testcase_14 AC 437 ms
56,832 KB
testcase_15 AC 367 ms
44,620 KB
testcase_16 AC 468 ms
61,824 KB
testcase_17 AC 435 ms
60,416 KB
testcase_18 AC 500 ms
56,768 KB
testcase_19 AC 540 ms
55,472 KB
testcase_20 AC 567 ms
57,760 KB
testcase_21 AC 565 ms
57,732 KB
testcase_22 AC 588 ms
60,672 KB
testcase_23 AC 563 ms
60,128 KB
testcase_24 AC 316 ms
44,416 KB
testcase_25 AC 303 ms
37,760 KB
testcase_26 AC 305 ms
46,464 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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}"
}
0