結果
問題 | 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_iB = gets.split(" ").map{|s| s.to_i}from = []to = []cnt = 0B.each_with_index {|n, i|if n == 0 thenif from.length > 0f = from.shiftcnt += i - felseto << iendelsewhile n > 1 and to.length > 0 dot = to.shiftcnt += i - tn -= 1endif n > 1 thenfrom.concat([i] * (n-1))endend}puts cnt