| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 
 | #include <cstdio>#include <cctype>
 #include<algorithm>
 using namespace std;
 const int Mn(100500);
 template<typename T> void qrd(T& x) {
 x = 0;
 int c = getchar();
 while(!isdigit(c)) {
 c = getchar();
 }
 while(isdigit(c)) {
 x = x*10 + c - '0';
 c = getchar();
 }
 }
 template<typename T, typename... Ts> void qrd(T& x,Ts&... xs) {
 qrd(x); qrd(xs...);
 }
 
 int n,m;
 struct Td {
 double mx;
 int len;
 } t[Mn<<2];
 int calc(int p,int l,int r,double qx) {
 if(l==r) {
 return (t[p].mx>qx);
 }
 int mid((l+r)/2);
 if(t[p<<1].mx<=qx) {
 return calc(p<<1|1,mid+1,r,qx);
 } else {
 return calc(p<<1,l,mid,qx) + t[p].len - t[p<<1].len;
 }
 }
 void mtn(int p,int l,int r) {
 t[p].mx = max(t[p<<1].mx, t[p<<1|1].mx);
 int mid((l+r)/2);
 int rl = calc(p<<1|1,mid+1,r,t[p<<1].mx);
 t[p].len = t[p<<1].len + rl;
 }
 void mdf(int mp,double mx,int p=1,int l=1,int r=n) {
 if(l==r) {
 t[p] = {mx,1};
 return;
 }
 int mid((l+r)/2);
 if(mp<=mid) {
 mdf(mp,mx,p<<1,l,mid);
 } else {
 mdf(mp,mx,p<<1|1,mid+1,r);
 }
 mtn(p,l,r);
 }
 
 int main() {
 qrd(n,m);
 while(m--) {
 int x,y;
 qrd(x,y);
 double k = 1.*y/x;
 mdf(x,k);
 printf("%d\n",t[1].len);
 }
 return 0;
 }
 
 
 |