1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <cstdio> #include <iostream> using namespace std; namespace Fast { const int L = (1 << 20) + 5; char buf[L], out[L], *iS, *iT; int l = 0; #define gh() (iT == iS ? iT = (iS = buf) + fread(buf, 1, L, stdin), (iT == iS ? EOF : *iS++) : *iS++) template<class T> void read(T &x) { x = 0; char ch = gh(), t = 0; while (ch < '0' || ch > '9') t |= ch == '-', ch = gh(); while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = gh(); if (t) x = -x; } void flus() { fwrite(out, 1, l, stdout); l = 0; } void putc(char x) { out[l++] = x; if (l == L - 5) flus(); } template<class T> void write(T x) { if (x < 0) putc('-'), x = -x; if (x > 9) write(x / 10); out[l++] = x % 10 + 48; if (l == L - 5) flus(); } } using Fast::flus; using Fast::putc; using Fast::read; using Fast::write; const int N = 1e5 + 5; int n, m, a[N]; float x; int main() { read(n), read(m); for (int i = 1; i <= n; i++) read(a[i]); while (m--) { int op, l, r, ans = 0; read(op), read(l), read(r), read(x); if (op == 1) for (int i = l; i <= r; i++) a[i] -= (a[i] > x) ? x : 0; else { for (int i = l; i <= r; i++) ans += !(a[i] - x); printf("%d\n", ans); } } return 0; }
|