Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
33686 22fhq 【S】rent C++ 通过 100 230 MS 16640 KB 1561 2024-10-18 14:32:09

Tests(20/20):


#include<bits/stdc++.h> using namespace std; #define int long long int n,m,k,d; struct node{ int m, l, r,s; void operator=(int y){ m=l=r=y; s=y; } }; void operator+=(node &x,int y){ x.m+=y,x.s+=y,x.l+=y,x.r+=y; return ; } node operator+(node x,node y){ return {max({x.m,y.m,x.r+y.l}),max(x.l,x.s+y.l),max(y.r,y.s+x.r),x.s+y.s}; } node t[2000006]; #define ls (p<<1) #define rs (p<<1|1) #define mid (l+r>>1) void pu(int p){ t[p]=t[ls]+t[rs]; } void bd(int l,int r,int p){ if(l==r){ t[p]=-k; return; } bd(l,mid,ls),bd(mid+1,r,rs); pu(p); return; } void upd(int l,int r,int id,int x,int p){ if(l==r){ // cout<<l<<" "<<r<<" "<<x<<endl; t[p]+=x; // cout<<t[p].s<<endl; return; } if(mid>=id)upd(l,mid,id,x,ls); else upd(mid+1,r,id,x,rs); pu(p); return; } inline void read(int &x){ x=0; char c=getchar(); bool f=0; while(!isdigit(c)){if(c=='-')f=1;c=getchar();} while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar(); if(f)x=-x; return; } signed main(){ //freopen("rent.in","r",stdin); //freopen("rent.out","w",stdout); read(n),read(m),read(k),read(d); bd(1,n,1); while(m--){ int p,x; read(p),read(x); upd(1,n,p,x,1); // cout<<t[1].m<<" "<<k*d<<endl; if(t[1].m>k*d)putchar('N'),putchar('O'),putchar('\n'); else putchar('Y'),putchar('E'),putchar('S'),putchar('\n'); } return 0; }


测评信息: