結果

問題 No.1618 Convolution?
ユーザー pengin_2000pengin_2000
提出日時 2021-07-22 21:47:11
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 1,033 ms
コンパイル使用メモリ 28,544 KB
実行使用メモリ 8,124 KB
最終ジャッジ日時 2023-09-24 16:24:27
合計ジャッジ時間 6,090 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 57 ms
7,180 KB
testcase_03 AC 67 ms
7,732 KB
testcase_04 AC 57 ms
6,908 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 74 ms
7,512 KB
testcase_07 AC 76 ms
7,328 KB
testcase_08 AC 58 ms
6,856 KB
testcase_09 AC 89 ms
7,944 KB
testcase_10 AC 61 ms
6,852 KB
testcase_11 AC 84 ms
7,808 KB
testcase_12 AC 90 ms
8,012 KB
testcase_13 AC 94 ms
8,124 KB
testcase_14 AC 90 ms
8,120 KB
testcase_15 AC 90 ms
8,044 KB
testcase_16 AC 91 ms
8,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i;
	long long int a[200005], b[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%lld", &b[i]);
	long long int c[400005];
	long long int sum = 0, v = 0;
	for (i = 0; i < n; i++)
	{
		c[i] = v;
		sum += a[i];
		v += sum;
	}
	for (i = n; i < 2 * n; i++)
	{
		c[i] = v;
		sum -= a[i - n];
		v += sum;
		v -= n * a[i - n];
	}
	v = 0;
	for (i = 0; i < n; i++)
	{
		c[i] += v;
		sum += b[i];
		v += sum;
	}
	for (i = n; i < 2 * n; i++)
	{
		c[i] += v;
		sum -= b[i - n];
		v += sum;
		v -= n * b[i - n];
	}
	for (i = 0; i < 2 * n - 1; i++)
		printf("%lld ", c[i]);
	printf("%lld\n", c[2 * n - 1]);
	return 0;
}
0