Pagini recente » Cod sursa (job #2450028) | Cod sursa (job #2664689) | Cod sursa (job #2688995) | Cod sursa (job #2724453) | Cod sursa (job #3200099)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("marbles.in");
ofstream fout("marbles.out");
const int Max = (1 << 17);
struct bila {
int p, c;
} q[Max + 2];
int n, m, i, r, v[Max + 2];
int a[Max + 2][66];
static inline bool Cmp(bila a, bila b) {
return (a.p < b.p);
}
int main() {
fin >> n >> m;
for(i = 1; i <= n; i++) fin >> q[i].p >> q[i].c;
sort(q + 1, q + n + 1, Cmp);
for(i = 1; i <= n; i++) {
v[i] = q[i].p;
a[i][q[i].c] = 1;
}
for(i = 1; i <= n; i++) {
for(int j = 1; j <= 64; j++) a[i][j] += a[i - 1][j];
}
for(i = 1; i <= m; i++) {
int op, x, y;
fin >> op >> x >> y;
if(op == 0) {
/// pe scurt: pozitia la care intalnesc pe x creste cu y
*lower_bound(v + 1, v + n + 1, x) += y;
}
else {
x = (lower_bound(v + 1, v + n + 1, x) - v);
y = (upper_bound(v + 1, v + n + 1, y) - v) - 1; /// pt ca upper bound
r = 0;
for(int i = 1; i <= 64; i++) r = max(r, a[y][i] - a[x - 1][i]);
fout << r << "\n";
}
}
return 0;
}