結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,796 KB
testcase_01 AC 2 ms
7,796 KB
testcase_02 AC 83 ms
8,464 KB
testcase_03 AC 97 ms
8,464 KB
testcase_04 AC 102 ms
8,464 KB
testcase_05 AC 11 ms
7,872 KB
testcase_06 AC 135 ms
8,464 KB
testcase_07 AC 135 ms
8,464 KB
testcase_08 AC 102 ms
8,464 KB
testcase_09 AC 161 ms
8,464 KB
testcase_10 AC 109 ms
8,464 KB
testcase_11 AC 155 ms
8,464 KB
testcase_12 AC 171 ms
8,464 KB
testcase_13 AC 172 ms
8,464 KB
testcase_14 AC 172 ms
8,464 KB
testcase_15 AC 170 ms
8,464 KB
testcase_16 AC 171 ms
8,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

int main()
{
	cin >> n;

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

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

	for (int i = 0; i < n; i++) {
		s[i] = a[i] + b[i];

		if (i > 0)
			s[i] += s[i - 1];
	}

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

		cout << t;

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