Pagini recente » Cod sursa (job #531742) | Cod sursa (job #87854) | Cod sursa (job #2844755) | Cod sursa (job #130392) | Cod sursa (job #2533235)
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int INF = 2e9;
const int N = 1e5;
const int CUL = 64;
vector <int> v[5 + CUL];
int cautst(int color, int elem){
int st, dr, mid, ans;
st = 1;
dr = v[color].size() - 1;
ans = dr + 1;
while(st <= dr){
mid = (st + dr) >> 1;
if(v[color][mid] >= elem){
ans = mid;
dr = mid - 1;
} else st = mid + 1;
}
return ans;
}
int cautdr(int color, int elem){
int st, dr, mid, ans(0);
st = 1;
dr = v[color].size() - 1;
while(st <= dr){
mid = (st + dr) >> 1;
if(v[color][mid] <= elem){
ans = mid;
st = mid + 1;
} else dr = mid - 1;
}
return ans;
}
int main()
{
freopen("marbles.in", "r", stdin);
freopen("marbles.out", "w", stdout);
int n, m, culmax(0);
scanf("%d%d", &n, &m);
for(int i = 1; i <= CUL; i++) v[i].push_back(0);
for(int i = 1; i <= n; i++){
int x, c;
scanf("%d%d", &x, &c);
v[c].push_back(x);
culmax = max(culmax, c);
}
for(int i = 1; i <= m; i++){
int tip, x, y, Max(0);
scanf("%d%d%d", &tip, &x, &y);
for(int j = 1; j <= culmax; j++){
if(tip == 0){
int pos = cautst(j, x);
if(v[j][pos] == x)
v[j][pos] += y;
} else{
int posst = cautst(j, x);
int posdr = cautdr(j, y);
Max = max(Max, posdr - posst + 1);
}
}
if(tip == 1)
printf("%d\n", Max);
}
fclose(stdin);
fclose(stdout);
return 0;
}