/* -*- coding: utf-8 -*- * * 2942.cc: No.2942 Sigma Music Game Level Problem - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 1000000; const int MAX_M = 200000; /* typedef */ using ll = long long; template struct BIT { int n; vector bits; BIT() {} BIT(int _n) { init(_n); } void init(int _n) { n = _n; bits.assign(n + 1, 0); } T sum(int x) { x = min(x, n); T s = 0; while (x > 0) { s += bits[x]; x -= (x & -x); } return s; } void add(int x, T v) { if (x <= 0) return; while (x <= n) { bits[x] += v; x += (x & -x); } } }; /* global variables */ int as[MAX_N]; BIT bit0; BIT bit1; /* subroutines */ /* main */ int main() { int n, qn, li; scanf("%d%d%d", &n, &qn, &li); for (int i = 0; i < n; i++) scanf("%d", as + i); bit0.init(MAX_M + 1); bit1.init(MAX_M + 1); for (int i = 0; i < n; i++) { bit0.add(as[i] + 1, 1); bit1.add(as[i] + 1, as[i]); } int qcs[3] = {0, 0, 0}; while (qn--) { int op; scanf("%d", &op); qcs[op - 1]++; if (op == 1) { int l; scanf("%d", &l); bit0.add(l + 1, 1); bit1.add(l + 1, l); } else if (op == 2) { int l, r; scanf("%d%d", &l, &r); int c = bit0.sum(r + 1) - bit0.sum(l); ll s = bit1.sum(r + 1) - bit1.sum(l); printf("%d %lld\n", c, s); } else { int m; scanf("%d", &m); li = m; } } if (! qcs[1]) puts("Not Found!"); //printf(" %d %d %d\n", qcs[0], qcs[1], qcs[2]); return 0; }