Pagini recente » Cod sursa (job #1948280) | Cod sursa (job #726376) | Diferente pentru problema/xp intre reviziile 15 si 2 | Cod sursa (job #3337848) | Cod sursa (job #3339797)
#include <bits/stdc++.h>
using namespace std;
#define USE_STD_IO 0
#if USE_STD_IO
#define fin cin
#define fout cout
#else
ifstream fin("marbles.in");
ofstream fout("marbles.out");
#endif
vector<int> poz[65];
int n, q, i, rasp;
static inline int CautBinSt(int cul, int caut) {
int st = 0, dr = poz[cul].size() - 1;
int mij, ret = dr;
while(st <= dr) {
mij = st + (dr - st) / 2;
if(caut <= poz[cul][mij]) {
ret = mij;
dr = mij - 1;
}
else st = mij + 1;
}
return ret;
}
static inline int CautBinDr(int cul, int caut) {
int st = 0, dr = poz[cul].size() - 1;
int mij, ret = st;
while(st <= dr) {
mij = st + (dr - st) / 2;
if(poz[cul][mij] <= caut) {
ret = mij;
st = mij + 1;
}
else dr = mij - 1;
}
return ret;
}
int main() {
if(USE_STD_IO) ios_base::sync_with_stdio(false);
fin.tie(NULL);
fout.tie(NULL);
fin >> n >> q;
for(i = 1; i <= n; i++) {
int p, c;
fin >> p >> c;
poz[c].push_back(p);
}
for(i = 1; i <= 64; i++) sort(poz[i].begin(), poz[i].end());
while(q--) {
int op, x, y;
fin >> op >> x >> y;
if(0 == op) {
for(i = 1; i <= 3; i++) {
int pp = CautBinSt(i, x);
if(x == poz[i][pp]) {
poz[i][pp] += y;
break;
}
}
}
else {
int ma = 0;
for(i = 1; i <= 3; i++) {
//fout << CautBinSt(i, x) << ' ' << CautBinDr(i, y) << '\n';
ma = max(ma, CautBinDr(i, y) - CautBinSt(i, x) + 1);
}
fout << ma << "\n";
}
}
return 0;
}