結果

問題 No.1618 Convolution?
ユーザー atjh16atjh16
提出日時 2021-10-20 21:20:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 3,245 ms
コンパイル使用メモリ 200,328 KB
実行使用メモリ 6,836 KB
最終ジャッジ日時 2023-10-20 11:09:30
合計ジャッジ時間 8,330 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,764 KB
testcase_01 AC 2 ms
5,764 KB
testcase_02 AC 82 ms
6,484 KB
testcase_03 AC 97 ms
6,716 KB
testcase_04 AC 103 ms
6,432 KB
testcase_05 AC 10 ms
5,840 KB
testcase_06 AC 133 ms
6,560 KB
testcase_07 AC 135 ms
6,568 KB
testcase_08 AC 106 ms
6,432 KB
testcase_09 AC 160 ms
6,824 KB
testcase_10 AC 110 ms
6,432 KB
testcase_11 AC 152 ms
6,736 KB
testcase_12 AC 170 ms
6,836 KB
testcase_13 AC 170 ms
6,836 KB
testcase_14 AC 172 ms
6,836 KB
testcase_15 AC 171 ms
6,832 KB
testcase_16 AC 172 ms
6,836 KB
権限があれば一括ダウンロードができます

ソースコード

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