GDKOI2023淋雨题解
先分析一下每个雨滴落下至
不难得到
因为上面的柿子有分数,不好算,所以整体乘上一个
根据题意我们设
转移就很显然了,
其中
拆开绝对值并移项可得两条不等柿:
-
v_c·t_i-p_i\le v_c \cdot t_j-p_j -
v_c·t_i+p_i\le v_c \cdot t_j+p_j
满足以上两条件的
记
因为我们只关心大小关系并且
然后我们把第
回到题目,他是有
我们可以将
发现在线没有不好处理,正难则反,那就离线处理,你不能每次询问都做一次dp。
先分别计算每个起点对应的
考虑当前枚举到第
最后树状数组维护的是前缀,所以要把所有的区间翻转一下。如
时间复杂度
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
const int N=1e5+5;
int n,q,s,vc,vg,vw,y[N],tr[N],ans[N];
struct point{
int t,p,x,y,id;
bool operator<(const point& CXK)const{
return x>CXK.x||x==CXK.x&&y>CXK.y;
}
}c[N],ask[N];
inline void update(int x,int k){
for(;x<=n;x+=x&-x)
tr[x]=max(tr[x],k);
}
inline int getmax(int x){
int res=0;
for(;x>0;x-=x&-x) res=max(res,tr[x]);
return res;
}
void Init(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>q>>vg>>vw>>vc;
for(re int i=1;i<=n;i++){
int x,y; cin>>x>>y;
c[i]={y,x*vg+y*vw,0,0,0};
}
for(re int i=1;i<=n;i++){
c[i].x=vc*c[i].t-c[i].p;
c[i].y=y[i]=vc*c[i].t+c[i].p;
}
}
signed main(){
Init();
for(re int i=1;i<=q;i++){
cin>>s; s*=vg;
ask[i]={0,s,-s,s,i};
}
sort(y+1,y+n+1);
sort(c+1,c+n+1);
sort(ask+1,ask+q+1);
for(re int i=1,j=1;i<=q;i++){
int ay=lower_bound(y+1,y+n+1,ask[i].y)-y;
while(c[j].x>=ask[i].x&&j<=n){
c[j].y=lower_bound(y+1,y+n+1,c[j].y)-y;
update(n-c[j].y+1,getmax(n-c[j].y+1)+1);
j++;
}
ans[ask[i].id]=getmax(n-ay+1);
}
for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';
return 0;
}