Pagini recente » Cod sursa (job #778893) | Cod sursa (job #1565990) | Cod sursa (job #1084844) | Cod sursa (job #870139) | Cod sursa (job #1538053)
#include <fstream>
#include <vector>
#include <array>
#include <vector>
#include <algorithm>
using namespace std;
constexpr int maxcul = 64;
struct punct{
int poz, cul; };
bool operator<(const punct& a, const punct& b){
return a.poz < b.poz || (a.poz == b.poz && a.cul < b.cul); }
int main(){
ifstream f("marbles.in");
ofstream g("marbles.out");
int n, m;
f >> n >> m;
vector<punct> pts(n);
for(auto& p : pts){
f >> p.poz >> p.cul;
--p.cul; }
sort(begin(pts), end(pts));
vector<array<int, maxcul> > s_part(n+1);
for(int i = n-1; i >= 0; --i){
s_part[i] = s_part[i+1];
++s_part[i][pts[i].cul]; }
for(int i = 0, t, x, y; i < m; ++i){
f >> t >> x >> y;
if(t == 0){
auto it = lower_bound(begin(pts), end(pts), (punct){ x, 0 });
it->poz += y; }
else{
int st = lower_bound(begin(pts), end(pts), (punct){x, 0}) - begin(pts),
dr = upper_bound(begin(pts), end(pts), (punct){y, 64}) - begin(pts);
int rez = 1;
for(int j = 0; j < maxcul; ++j){
rez = max(rez, s_part[st][j] - s_part[dr][j]); }
g << rez << '\n'; } }
return 0; }