Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- const int baza = (1<<4);
- long long drzewo[baza];
- long long nwm[baza];
- void push(int v){
- nwm[v*2]+=nwm[v];
- drzewo[v*2]+=nwm[v];
- nwm[v*2+1]+=nwm[v];
- drzewo[v*2+1]+=nwm[v];
- nwm[v]=0;
- return;
- }
- void update(int v){
- drzewo[v]=max(drzewo[v*2],drzewo[v*2+1]);
- return;
- }
- void add(int a,int b,int c, int v=1,int l=1,int r=baza){
- if(l>b||r<a){
- return;
- }
- if(l>=a&&r<=b){
- drzewo[v]+=c;
- nwm[v]+=c;
- return;
- }
- push(v);
- int s=(l+r)/2;
- add(a,b,c,2*v,l,s);
- add(a,b,c,2*v+1,s+1,r);
- update(v);
- return;
- }
- int main()
- {
- int s,w;
- int n;
- int x,y;
- vector <int> tabx[60002]={};
- cin>>s>>w>>n;
- for(int i=0;i<n;i++){
- cin>>x>>y;
- //x+=30001;
- //y+=30001;
- x+=1;
- y+=1;
- tabx[x].push_back(y);
- }
- long long mm=0;
- for(int i=0;i<60002;i++){
- if(i>=s){
- for(int j=0;j<tabx[i-s].size();j++){
- add(tabx[i-s][j],tabx[i-s][j]+w,-1);
- }
- }
- for(int j=0;j<tabx[i].size();j++){
- add(tabx[i][j],tabx[i][j]+w,1);
- cout<<drzewo[1]<<endl;
- }
- mm=max(mm,drzewo[1]);
- }
- cout<<mm;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement