多谢
by later,when @ 2020-01-17 18:53:11
实测暴力可过($\text{for}$ 循环)
而且理论上这题要开 $\text{long}$ $\text{long}$,没开也过了。
```cpp
#include <stdio.h>
#include <ctype.h>
#define N 100005
#define R register
int n, m, l, r, k, d, a[N];
char Buf[1 << 24], *S(Buf), *T(Buf);
#define getchar() (S == T && (T = (S = Buf) + fread(Buf, 1, 1 << 24, stdin), S == T) ? EOF : *S++)
inline int input() {
R int x(0), f(0);
R char c(getchar());
while (!isdigit(c)) f |= (c == '-'), c = getchar();
while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
return f ? -x : x;
}
int main() {
n = input(), m = input();
for (int i = 1; i <= n; ++i) a[i] = input();
for (int i = n; i >= 1; --i) a[i] -= a[i - 1];
for (int i = 1; i <= m; ++i) {
if (input() == 1) {
l = input(), r = input(), k = input(), d = input();
a[l] += k;
for (int j = l + 1; j <= r; ++j) a[j] += d;
if (r != n)
a[r + 1] -= k + d * (r - l);
} else {
int ret = 0;
for (int i = input(); i >= 1; --i) ret += a[i];
printf("%d\n", ret);
}
}
return 0;
}
```
才 $300\text{ms}$,是不是很快?
建议加强数据。
https://www.luogu.com.cn/record/35321235
@[chen_zhe](/user/8457)
by StevenLu1103 @ 2020-07-18 16:25:40
差点因为这手找一万个数据
by theStarMaster @ 2021-08-21 19:49:21
@[Andrew82](/user/109378) 感谢
by Emotiona @ 2021-08-23 12:36:16