为啥洛谷AC,实测却爆零了
查看原帖
为啥洛谷AC,实测却爆零了
104487
Shui_Dream楼主2020/4/29 17:06
#include<bits/stdc++.h>

using namespace std;
int n,L,v;
double k=1;
long double t[200005];
long long a[200005];
bool cmd(long long  x,long long y)
{
	return x>y;
}
int main()
{
	freopen("endless.in","r",stdin);
	freopen("endless.out","w",stdout);
	scanf("%d%d%d",&n,&L,&v);
	k=1;
	k/=v;
	t[0]=k*L;
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmd);
	for(int i=1;i<=n;i++)
		t[i]=t[i-1]+a[i]*k;
	int m;
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		long long x;
		scanf("%ld",&x);
		if(t[0]>x)
		{
			printf("0\n");
			continue;
		}
		if(t[n]<=x)
		{
			printf("-1\n");
			continue;
		}
		int l=0,r=n;
		while(l+1<r)
		{
			int mid=(l+r)/2;
			if(t[mid]<=x) l=mid;
			else r=mid;
		}
		cout<<r<<"\n";
	}

	return 0;
}

这个程序我在luogu上测试AC的,我在NOIOJ上却惨遭爆零,freopen也没出错,请问是快读的问题吗

2020/4/29 17:06
加载中...