Official
C - 果樹園の収穫計画 / Orchard Harvest Plan Editorial
by
C - 果樹園の収穫計画 / Orchard Harvest Plan Editorial
by
sounansya
Editorial for printing
\(\displaystyle B_i=\sum_{j=1}^i A_i\) (\(A\) の累積和)とします。
このとき、求める値は \(\displaystyle \sum_{i=L_j}^{R_j} A_i\times T_j = T_j(B_{R_j}-B_{L_j-1})\) となります。
n, q = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n):
b[i + 1] = b[i] + a[i]
for i in range(q):
l, r, t = map(int, input().split())
print(t * (b[r] - b[l - 1]))
posted:
last update:
