結果

問題 No.1618 Convolution?
ユーザー simansiman
提出日時 2022-10-13 01:49:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 588 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 11,408 KB
実行使用メモリ 50,316 KB
最終ジャッジ日時 2023-09-08 18:44:21
合計ジャッジ時間 15,020 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,180 KB
testcase_01 AC 78 ms
15,112 KB
testcase_02 AC 411 ms
44,580 KB
testcase_03 AC 474 ms
46,344 KB
testcase_04 AC 383 ms
37,388 KB
testcase_05 AC 102 ms
16,320 KB
testcase_06 AC 493 ms
46,944 KB
testcase_07 AC 493 ms
46,960 KB
testcase_08 AC 386 ms
37,784 KB
testcase_09 AC 578 ms
49,580 KB
testcase_10 AC 404 ms
38,320 KB
testcase_11 AC 548 ms
50,316 KB
testcase_12 AC 588 ms
50,036 KB
testcase_13 AC 585 ms
49,884 KB
testcase_14 AC 582 ms
49,852 KB
testcase_15 AC 587 ms
49,972 KB
testcase_16 AC 585 ms
50,036 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = Array.new(2 * N + 1, 0)

sum_a = 0
rui_a = 0
A.each.with_index(1) do |a, i|
  sum_a += rui_a
  sum_a += a
  C[i] += sum_a

  rui_a += a
end

A.each.with_index(1) do |a, i|
  sum_a -= N * a
  rui_a -= a
  sum_a += rui_a
  C[i + N] += sum_a
end

sum_b = 0
rui_b = 0
B.each.with_index(1) do |b, i|
  sum_b += rui_b
  sum_b += b
  C[i] += sum_b

  rui_b += b
end

B.each.with_index(1) do |b, i|
  sum_b -= N * b
  rui_b -= b
  sum_b += rui_b
  C[i + N] += sum_b
end

puts C[0..-2].join(' ')
0