跳到正文

个人记录

顶顶顶

leyitianzun约 4 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 4 分钟

版本

  1. v1当前
C++
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
double eps=1e-10;
int n,m,L,V;
struct sx{
	int d,v,a;
}a[100001];
struct node{
	int l,r;
}b[100001];
int p[100001];
int cnt;
int t;
bool cmp(node a1,node b1){
	if(a1.l !=b1.l )return a1.l <b1.l ;
	else return a1.r <b1.r ;
}
int main(){
//	freopen("p11232.in","r",stdin);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	cin>>t;
	while(t--){
		cin>>n>>m>>L>>V;
	for(int c=1;c<=n;c++){
		cin>>a[c].d >>a[c].v >>a[c].a ;
	}
	for(int c=1;c<=m;c++){
		cin>>p[c];
	}
	for(int c=1;c<=n;c++){
		if(a[c].a ==0){
			if(V>=a[c].v ){
				continue;
			}
			int id=lower_bound(p+1,p+1+m,a[c].d )-p;
			if(id>m){
				continue;
			}
			cnt++;
			b[cnt].l =id;
			b[cnt].r =m;
//			cout<<c<<" "<<id<<" "<<m<<endl;
		}
		else if(a[c].a >0){
			if(V<=a[c].v ){
				int id=lower_bound(p+1,p+1+m,a[c].d )-p;
				if(id>m){
					continue;
				}
				cnt++;
				b[cnt].l =id;
				b[cnt].r =m;
//				cout<<c<<" "<<id<<" "<<m<<endl;
			}
			else{
				double t=(double)(V-a[c].v)/a[c].a ;
				double s=a[c].v *t+0.5*a[c].a *t*t+eps;
				int sum=(int)ceil((double)a[c].d +s);
				int id=lower_bound(p+1,p+1+m,sum)-p;
				if(id>m)continue;
				cnt++;
				b[cnt].l =id;
				b[cnt].r =m;
//				cout<<c<<" "<<id<<" "<<m<<endl;
			}
		}
		else{
			if(V>=a[c].v )continue;
			double t=(double)(V-a[c].v )/a[c].a ;
			double s=a[c].v *t+0.5*a[c].a *t*t-eps;
			int sum=(int)ceil((double)a[c].d +s);
			int l=lower_bound(p+1,p+1+m,a[c].d )-p;
			int r=lower_bound(p+1,p+1+m,sum)-p-1;
			//
			if(p[r]==sum)r--;
			//
			if(l>r)continue;
			cnt++;
			b[cnt].l =l;
			b[cnt].r =r;
//				cout<<c<<" "<<l<<" "<<r<<endl;
		}
	}
	cout<<cnt<<" ";
	sort(b+1,b+1+cnt,cmp);
//	cout<<endl;
//	for(int c=1;c<=cnt;c++){
//		cout<<c<<" "<<b[c].l <<" "<<b[c].r <<endl;
//	}
	int rr=0,ans=0;
	for(int c=1;c<=cnt;c++){
		if(rr>=b[c].l )continue;
		else{
			ans++;
			rr=max(rr,b[c].r );
		}
	}
	cout<<m-ans<<endl;
	}

}
原文