結果

問題 No.1618 Convolution?
ユーザー atjh16
提出日時 2021-10-20 21:20:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 191,936 KB
最終ジャッジ日時 2025-01-25 02:05:33
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long n, t;
long long a[200000], b[200000];

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n; i++) {
		cin >> t;
		a[i] += t;

		if (i == 0)
			b[i] = a[i];
		else
			b[i] = b[i - 1] + a[i];
	}

	for (int i = 0; i < n * 2; i++) {
		if (i == 0)
			t = 0;
		else if (i < n + 1)
			t = t + b[i - 1];
		else
			t = t + b[n - 1] - b[i - n - 1] - n * a[i - n - 1];

		cout << t;

		if (i < n * 2 - 1)
			cout << " ";
		else
			cout << endl;
	}
}
0