#901. 区间修改,单点查询

区间修改,单点查询

Cannot parse: (0 , import_utils.normalizeSubtasks) is not a function or its return value is not iterable

Background

Special for beginners, ^_^

Description

这是一道模板题。

给定数列 a[1], a[2], \dots, a[n],你需要依次进行 q 个操作,操作有两类:

  • 1 l r x:给定 l,r,x,对于所有 i[l,r]i\in[l,r],将 a[i] 加上 x(换言之,将 a[l], a[l+1],\dots, a[r] 分别加上 x);
  • 2 i:给定 i,求 a[i] 的值。

Format

Input

第一行包含 2 个正整数 n,q,表示数列长度和询问个数。保证 1n,q1061\le n,q\le 10^6。 第二行 n 个整数 a[1], a[2], \dots, a[n],表示初始数列。保证 a[i]106|a[i]|\le 10^6。 接下来 q 行,每行一个操作,为以下两种之一:

  • 1 l r x:对于所有 i[l,r]i\in[l,r],将 a[i] 加上 x
  • 2 i:给定 i,求 a[i] 的值。

保证 1lrn,x1061\le l\le r\le n, |x|\le 10^6

Output

对于每个 2 i 操作,输出一行,每行有一个整数,表示所求的结果。

Samples

3 2
1 2 3
1 1 3 0
2 2
2

Limitation

对于所有数据,$1\le n,q\le 10^6, |a[i]|\le 10^6, 1\le l\le r\le n, |x|\le 10^6$。

1s, 1024KiB for each test case.