結果

問題 No.929 よくあるボールを移動するやつ
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-06 13:16:23
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 241 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 11,488 KB
実行使用メモリ 22,304 KB
最終ジャッジ日時 2023-08-24 19:51:21
合計ジャッジ時間 2,983 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,172 KB
testcase_01 AC 78 ms
15,124 KB
testcase_02 AC 78 ms
15,088 KB
testcase_03 AC 79 ms
15,144 KB
testcase_04 AC 78 ms
15,248 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
B = gets.split.map(&:to_i)
S = Array.new(N + 1, 0)
B.each_with_index do |b,i|
  S[i + 1] = S[i] + b
end

t = 0
(1 .. N).inject(0) do |m, n|
  m_ = S[m] >= n ? m : (m .. N).find{|m_| S[m_] >= n }
  t += (n - m_).abs
end

puts t
0