結果

問題 No.1618 Convolution?
ユーザー ayaoniayaoni
提出日時 2021-07-22 22:12:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 174,368 KB
最終ジャッジ日時 2023-09-24 17:17:52
合計ジャッジ時間 7,583 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,508 KB
testcase_01 AC 73 ms
71,356 KB
testcase_02 AC 222 ms
161,848 KB
testcase_03 AC 247 ms
174,368 KB
testcase_04 AC 209 ms
152,424 KB
testcase_05 AC 95 ms
79,344 KB
testcase_06 AC 236 ms
149,124 KB
testcase_07 AC 224 ms
154,244 KB
testcase_08 AC 202 ms
152,908 KB
testcase_09 AC 244 ms
149,224 KB
testcase_10 AC 211 ms
156,492 KB
testcase_11 AC 242 ms
151,448 KB
testcase_12 AC 242 ms
145,636 KB
testcase_13 AC 242 ms
144,612 KB
testcase_14 AC 245 ms
145,976 KB
testcase_15 AC 240 ms
144,464 KB
testcase_16 AC 251 ms
146,016 KB
権限があれば一括ダウンロードができます

ソースコード

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