Cod sursa(job #2552273)

Utilizator DenisONIcBanu Denis Andrei DenisONIc Data 20 februarie 2020 18:40:58
Problema Marbles Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.96 kb
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.first << ' ' << p.second << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 500005
const long double PI = acos(-1);

int n,m,pos,c,t,a,b;
vector<int> v[65];


int main(){
  ios::sync_with_stdio(false);
  freopen("marbles.in","r",stdin);
  freopen("marbles.out","w",stdout);

  scanf("%d%d", &n, &m);
  for (int i=1;i<=n;i++){
  	scanf("%d%d", &pos, &c);
  	v[c].push_back(pos);
  }

  for (int i=1;i<=m;i++){
  	scanf("%d%d%d", &t, &a, &b);
  	if (t == 0){
  		for (int c = 1; c <= 64; c++){
  			int x = lower_bound(v[c].begin(), v[c].end(), a) - v[c].begin();
  			if (x < v[c].size() && v[c][x] == a){
  				v[c][x] += b;
  				break;
  			}
  		}
  	}
  	else{
  		int ans = 0;
  		for (int c = 1; c <= 64; c++){
  			int st = lower_bound(v[c].begin(), v[c].end(), a) - v[c].begin();
  			int dr = upper_bound(v[c].begin(), v[c].end(), b) - v[c].begin();
  			ans = max(ans, dr-st);
  		}
  		cout << ans << '\n';
  	}
  }
  
  return 0;
}