/* -*- 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), bit1.init(MAX_M); for (int i = 0; i < n; i++) { bit0.add(as[i], 1); bit1.add(as[i], as[i]); } int q2 = 0; while (qn--) { int op; scanf("%d", &op); if (op == 1) { int l; scanf("%d", &l); bit0.add(l, 1); bit1.add(l, l); } else if (op == 2) { int l, r; scanf("%d%d", &l, &r), l--; int c = bit0.sum(r) - bit0.sum(l); ll s = bit1.sum(r) - bit1.sum(l); printf("%d %lld\n", c, s); q2++; } else if (op == 3) { int m; scanf("%d", &m); li = m; } } if (q2 == 0) puts("Not Found!"); return 0; }