結果

問題 No.1618 Convolution?
ユーザー simansiman
提出日時 2022-10-12 12:52:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 596 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 11,252 KB
実行使用メモリ 50,248 KB
最終ジャッジ日時 2023-09-08 13:58:37
合計ジャッジ時間 13,721 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,296 KB
testcase_01 AC 78 ms
15,152 KB
testcase_02 AC 417 ms
44,544 KB
testcase_03 AC 476 ms
46,644 KB
testcase_04 AC 387 ms
37,484 KB
testcase_05 AC 102 ms
16,304 KB
testcase_06 AC 498 ms
46,904 KB
testcase_07 AC 501 ms
46,984 KB
testcase_08 AC 390 ms
37,652 KB
testcase_09 AC 584 ms
49,476 KB
testcase_10 AC 407 ms
38,396 KB
testcase_11 AC 557 ms
50,248 KB
testcase_12 AC 594 ms
50,072 KB
testcase_13 AC 590 ms
50,024 KB
testcase_14 AC 591 ms
50,096 KB
testcase_15 AC 596 ms
49,928 KB
testcase_16 AC 584 ms
49,896 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