#include using namespace std; #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef long double ld; typedef unsigned long long ull; using P=pair; const int INF=1001001001; const int mod=1e9+7; struct SegmentTree { private: int n; vector

node; public: SegmentTree(vector

v) { int sz = v.size(); n = 1; while(n < sz) n *= 2; node.resize(2*n-1); for(int i=0; i=0; i--) node[i] = max(node[2*i+1], node[2*i+2]); } void add(int x, ll val) { x += (n - 1); node[x].first += val; while(x > 0) { x = (x - 1) / 2; node[x] = max(node[2*x+1], node[2*x+2]); } } P getmax(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return {0,0}; if(a <= l && r <= b) return node[k]; auto vl = getmax(a, b, 2*k+1, l, (l+r)/2); auto vr = getmax(a, b, 2*k+2, (l+r)/2, r); return max(vl, vr); } }; void solve(){ int n,m; cin>>n>>m; vector

a(m); rep(i,m){ cin>>a[i].first; a[i].second=i+1; } int q; cin>>q; SegmentTree seg(a); rep(i,q){ ll t,x,y; cin>>t>>x>>y; x--; if(t==1){ seg.add(x,y); } else if(t==2){ seg.add(x,-y); } else{ auto p=seg.getmax(0,m+1); cout<