結果

問題 No.1618 Convolution?
ユーザー kimiyukikimiyuki
提出日時 2021-07-22 22:27:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 86,520 KB
実行使用メモリ 174,300 KB
最終ジャッジ日時 2023-09-24 17:39:23
合計ジャッジ時間 9,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
80,096 KB
testcase_01 AC 163 ms
80,028 KB
testcase_02 AC 316 ms
168,828 KB
testcase_03 AC 328 ms
174,300 KB
testcase_04 AC 293 ms
149,384 KB
testcase_05 AC 194 ms
85,340 KB
testcase_06 AC 318 ms
136,352 KB
testcase_07 AC 322 ms
136,308 KB
testcase_08 AC 292 ms
149,536 KB
testcase_09 AC 352 ms
147,696 KB
testcase_10 AC 308 ms
156,240 KB
testcase_11 AC 340 ms
146,796 KB
testcase_12 AC 359 ms
161,180 KB
testcase_13 AC 358 ms
160,952 KB
testcase_14 AC 358 ms
160,968 KB
testcase_15 AC 356 ms
161,012 KB
testcase_16 AC 354 ms
161,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
from typing import *


def solve1(n: int, a: List[int]) -> List[int]:
    c = [0 for _ in range(2 * n)]
    for j in range(n):
        c[j + 1] += a[j]
        if j + n + 1 < 2 * n:
            c[j + n + 1] -= a[j]
    for k in range(2 * n - 1):
        c[k + 1] += c[k]
    for j in range(n):
        if j + n + 1 < 2 * n:
            c[j + n + 1] -= n * a[j]
    for k in range(2 * n - 1):
        c[k + 1] += c[k]
    return c

def solve(n: int, a: List[int], b: List[int]) -> List[int]:
    c1 = solve1(n, a)
    c2 = solve1(n, b)
    c = list(map(lambda x, y: x + y, c1, c2))
    return c


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = solve(n, a, b)
    print(*ans)


if __name__ == '__main__':
    main()
0