結果

問題 No.1000 Point Add and Array Add
ユーザー gemmarogemmaro
提出日時 2020-02-28 21:50:56
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 411 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 48,384 KB
最終ジャッジ日時 2024-04-21 18:20:48
合計ジャッジ時間 6,062 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
17,536 KB
testcase_01 AC 73 ms
12,032 KB
testcase_02 AC 74 ms
12,288 KB
testcase_03 AC 74 ms
12,160 KB
testcase_04 AC 74 ms
12,288 KB
testcase_05 AC 74 ms
12,160 KB
testcase_06 AC 71 ms
12,288 KB
testcase_07 AC 74 ms
12,160 KB
testcase_08 AC 73 ms
12,288 KB
testcase_09 AC 72 ms
12,160 KB
testcase_10 AC 74 ms
12,288 KB
testcase_11 AC 75 ms
12,160 KB
testcase_12 AC 103 ms
12,672 KB
testcase_13 AC 86 ms
12,672 KB
testcase_14 AC 152 ms
12,672 KB
testcase_15 AC 130 ms
12,416 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

N, Q = gets.chomp.split.map(&:to_i)
AS = gets.chomp.split.map(&:to_i)
COMMANDS = Q.times.map { gets.chomp.split }

arr_a = AS
arr_b = Array.new(N, 0)
COMMANDS.each do |command|
  x = command[1].to_i
  y = command[2].to_i
  case command[0]
  when 'A'
    arr_a[x - 1] += y
  when 'B'
    (x - 1..y - 1).each do |i|
      arr_b[i] += arr_a[i]
    end
  end
end

puts arr_b.join(' ')
0