题目描述
Description
给出一个长为 n 的数列,以及 n 个操作,操作涉及区间加法,单点查值。
Input
第一行输入一个数字 n。
第二行输入 n 个数字,第 i 个数字为 ai,以空格隔开。
接下来输入 n行询问,每行输入四个数字 opt、l、r、c,以空格隔开。
若 opt=0,表示将位于 [l,r]的之间的数字都加 c。
若 opt=1,表示询问 ar 的值(l 和 c 忽略)。
1≤n≤50000,-2^31 ≤others、ans≤2^31-1
Output
对于每次询问,输出一行一个数字表示答案。
Sample Input
4
1 2 2 3
0 1 3 1
1 0 1 0
0 1 2 2
1 0 2 0
Sample Output
2
5
代码部分
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int n,blo,q,l,r,ans;
int a[N],bl[N],tag[N];
int Max[N];