Pagini recente » Cod sursa (job #3327322) | Cod sursa (job #1532445) | Cod sursa (job #114347) | Cod sursa (job #2926286) | Cod sursa (job #3311645)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ifstream fin("marbles.in");
ofstream fout("marbles.out");
const int VMAX = 64;
int n, m;
ordered_set s[VMAX + 1];
map<int, int> mp;
int get_cnt(int c, int i, int j) {
return s[c].order_of_key(j + 1) - s[c].order_of_key(i);
}
int query(int i, int j) {
int answer = 0;
for(int c = 1; c <= VMAX; c++) {
answer = max(answer, get_cnt(c, i, j));
}
return answer;
}
void update(int i, int j) {
int c = mp[i];
s[c].erase(i);
mp.erase(i);
i += j;
s[c].insert(i);
mp[i] = c;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
fin >> n >> m;
for(int i = 1; i <= n; i++) {
int x, c;
fin >> x >> c;
mp[x] = c;
s[c].insert(x);
}
while(m--) {
int type, i, j;
fin >> type >> i >> j;
if(type == 0) {
update(i, j);
}
else {
fout << query(i, j) << '\n';
}
}
return 0;
}