結果

問題 No.1618 Convolution?
ユーザー ayaoni
提出日時 2021-07-22 22:12:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 172,404 KB
最終ジャッジ日時 2024-07-17 18:11:02
合計ジャッジ時間 7,229 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import accumulate
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
A = [0]+LI()
B = [0]+LI()
SA = list(accumulate(A))
SB = list(accumulate(B))
SSA = list(accumulate(SA))
SSB = list(accumulate(SB))

SA2 = [0]*(N+2)
SB2 = [0]*(N+2)
for i in range(N,-1,-1):
    SA2[i] = SA2[i+1]+A[i]
    SB2[i] = SB2[i+1]+B[i]

C = [SSA[i]+SSB[i] for i in range(N+1)]
for i in range(1,N):
    c = C[-1]+SA2[i+1]+SB2[i+1]-N*A[i]-N*B[i]
    C.append(c)

print(*C)
0