結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー simansiman
提出日時 2020-10-22 19:21:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 260 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 11,348 KB
実行使用メモリ 26,896 KB
最終ジャッジ日時 2023-09-28 14:45:41
合計ジャッジ時間 5,605 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,264 KB
testcase_01 AC 86 ms
15,112 KB
testcase_02 AC 147 ms
21,840 KB
testcase_03 AC 91 ms
15,748 KB
testcase_04 AC 160 ms
21,552 KB
testcase_05 AC 90 ms
15,312 KB
testcase_06 AC 174 ms
22,536 KB
testcase_07 AC 132 ms
20,708 KB
testcase_08 AC 186 ms
26,440 KB
testcase_09 AC 135 ms
21,076 KB
testcase_10 AC 147 ms
21,636 KB
testcase_11 AC 189 ms
26,660 KB
testcase_12 AC 138 ms
21,132 KB
testcase_13 AC 137 ms
20,844 KB
testcase_14 AC 175 ms
22,504 KB
testcase_15 AC 157 ms
21,744 KB
testcase_16 AC 117 ms
18,076 KB
testcase_17 AC 86 ms
15,320 KB
testcase_18 AC 118 ms
18,424 KB
testcase_19 AC 133 ms
20,700 KB
testcase_20 AC 128 ms
19,540 KB
testcase_21 AC 138 ms
21,140 KB
testcase_22 AC 82 ms
15,064 KB
testcase_23 AC 82 ms
15,324 KB
testcase_24 AC 190 ms
26,896 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, D = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = [0]
A.each do |a|
  B << B.last + a
end

pos = 0
ans = [0]

B[1..-1].each do |b|
  np = pos + D

  if np <= b
    ans << b
    pos = b
  else
    ans << np
    pos = np
  end
end

puts ans.join(' ')
0