P4198

胶过,唐

#include<bits/stdc++.h>
using namespace std;
int n,m;
double a[100010];
struct node {
	double mx;
	int len;
#define m(x) t[x].mx
#define l(x) t[x].len
} t[4*100010];
void pushup1(int x) {
	m(x)=max(m(x<<1),m(x<<1|1));
}
int pushup2(double lx,int x,int l,int r) {
	if(m(x)<=lx) return 0;
	if(a[l]>lx) return l(x);
	if(l==r) return a[l]>lx;
	int s1=x<<1,s2=x<<1|1;
	int mid=(l+r)>>1;
	if(m(s1)<=lx) return pushup2(lx,s2,mid+1,r);
	else return pushup2(lx,s1,l,mid)+l(x)-l(s1);
}
void chan(int x,int l,int r,int to,int c) {
	if(l==r&&l==to) {
		m(x)=(double)c/to;
		l(x)=1;
		return ;
	}
	int mid=(l+r)>>1;
	if(to<=mid) chan(x<<1,l,mid,to,c);
	else if(to>mid) chan(x<<1|1,mid+1,r,to,c);
	pushup1(x);
	l(x)=l(x<<1)+pushup2(m(x<<1),x<<1|1,mid+1,r);
}
int main() {
	scanf("%d%d",&n,&m);
	int x,y;
	for(int i=1; i<=m; i++) {
		scanf("%d%d",&x,&y);
		a[x]=(double)y/x;
		chan(1,1,n,x,y);
		printf("%d\n",t[1].len);
	}
	return 0;
}
posted @ 2024-10-22 16:53  yzc_is_SadBee  阅读(3)  评论(0编辑  收藏  举报