RE,但不知道为什么
查看原帖
RE,但不知道为什么
676613
Audrey_Hall楼主2022/10/23 18:34
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e7+5;
const double g=9.8;
int n,m,v,a,l=1,sub[N];
int ans;
struct node{
	int x,y,w,id;
	double t,ed;
	bool operator <(const node &u)const{
		return y<=u.y;
	}
}d[N];
bool cmp(node a,node b){
	return a.id<b.id;
}
signed main(){
//	freopen("missile4.in","r",stdin);
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%lld%lld%lld",&d[i].x,&d[i].y,&v),d[i].id=i,d[i].t=sqrt(2*d[i].y/g),d[i].ed=d[i].x+v*d[i].t;
	sort(d+1,d+n+1);
	for(int i=2;i<=n+1;++i)
		if(d[i].y!=d[i-1].y){
			for(int j=l;j<i;++j)
				for(int k=l;k<j;++k)
					if((d[j].x-d[k].x)*(d[j].ed-d[k].ed)<0||d[j].ed==d[k].ed)
						d[j].w++,d[k].w++;
			l=i;
		}
	sort(d+1,d+n+1,cmp);
	for(int i=1;i<=n;++i)
		scanf("%lld",&a),sub[i]=min(a,d[i].w),ans+=d[i].w;
	sort(sub+1,sub+n+1);
	for(int i=0;i<m;++i)
		ans-=sub[n-i];
	printf("%lld",ans);
	return 0;
}

全部返回:

Runtime Error. Received signal 11: Segmentation fault with invalid memory reference.

不知道为什么会 RE,我知道这不是正解,但为什么会 RE 啊 QAQ

调了半天了,请大家帮帮忙吧 QAQ

2022/10/23 18:34
加载中...