Pagini recente » Cod sursa (job #2476909) | Cod sursa (job #2639817) | Cod sursa (job #1485138) | Cod sursa (job #2586581) | Cod sursa (job #3277220)
#include <bits/stdc++.h>
using namespace std;
const int MAX = 64;
vector<int> colors[MAX];
int main()
{
ifstream cin("marbles.in");
ofstream cout("marbles.out");
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; ++i)
{
int coord, color;
cin >> coord >> color;
colors[color].push_back(coord);
}
for (int i = 1; i <= MAX; ++i)
sort(colors[i].begin(), colors[i].end());
for (int i = 1; i <= k; ++i)
{
int type, x, y;
cin >> type >> x >> y;
if (type == 0)
{
for (int j = 1; j <= 64; ++j)
{
auto pos = lower_bound(colors[j].begin(), colors[j].end(), x);
if (pos != colors[j].end())
{
colors[j].erase(pos);
auto findPos = lower_bound(colors[j].begin(), colors[j].end(), x+y);
colors[j].insert(findPos, x+y);
}
}
}
else
{
int ans = 0;
for (int j = 1; j <= 64; ++j)
{
auto pos1 = lower_bound(colors[j].begin(), colors[j].end(), x);
auto pos2 = upper_bound(colors[j].begin(), colors[j].end(), y);
ans = max(ans, (int)(pos2-pos1));
}
cout << ans << "\n";
}
}
return 0;
}