結果

問題 No.1618 Convolution?
ユーザー mkawa2mkawa2
提出日時 2021-07-22 21:51:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 696 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 73,692 KB
最終ジャッジ日時 2023-09-24 16:35:00
合計ジャッジ時間 13,497 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,276 KB
testcase_01 AC 16 ms
8,248 KB
testcase_02 AC 481 ms
44,696 KB
testcase_03 AC 595 ms
51,960 KB
testcase_04 AC 445 ms
49,256 KB
testcase_05 AC 48 ms
11,080 KB
testcase_06 AC 580 ms
62,000 KB
testcase_07 AC 572 ms
62,104 KB
testcase_08 AC 449 ms
49,968 KB
testcase_09 AC 689 ms
72,804 KB
testcase_10 AC 483 ms
52,232 KB
testcase_11 AC 656 ms
69,336 KB
testcase_12 AC 687 ms
73,692 KB
testcase_13 AC 683 ms
73,548 KB
testcase_14 AC 696 ms
73,552 KB
testcase_15 AC 695 ms
73,516 KB
testcase_16 AC 682 ms
73,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

def cs(aa):
    res = [0]
    for a in aa: res.append(res[-1]+a)
    return res

n = II()
aa = LI()
bb = LI()
sa = cs(aa)
sb = cs(bb)

cc = [0]*2*n
x = y = 0
for i in range(2*n):
    if i <= n:
        x += sa[i]
        y += sb[i]
    else:
        j = i-n-1
        x += sa[n]-sa[j+1]-aa[j]*n
        y += sb[n]-sb[j+1]-bb[j]*n
    cc[i] = x+y

print(*cc)
0