結果
| 問題 |
No.929 よくあるボールを移動するやつ
|
| ユーザー |
|
| 提出日時 | 2021-11-09 18:26:26 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 139 ms / 2,000 ms |
| コード長 | 355 bytes |
| コンパイル時間 | 52 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 20,096 KB |
| 最終ジャッジ日時 | 2024-11-18 21:26:38 |
| 合計ジャッジ時間 | 2,762 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i
B = gets.split(" ").map{|s| s.to_i}
from = []
to = []
cnt = 0
B.each_with_index {|n, i|
if n == 0 then
if from.length > 0
f = from.shift
cnt += i - f
else
to << i
end
else
while n > 1 and to.length > 0 do
t = to.shift
cnt += i - t
n -= 1
end
if n > 1 then
from.concat([i] * (n-1))
end
end
}
puts cnt