奇怪的WA增加了
查看原帖
奇怪的WA增加了
332022
ChthollyMeow楼主2020/5/1 20:43

蒟蒻求助一下

#include<bits/stdc++.h>
using namespace std;
double L,v,a[200010],s[200010],t,y;
int n,q,ans;
bool cmp(int r,int s){
	return r>s;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>L>>v;
	y=L/v;
	for(int i=1;i<=n;i++){			
		cin>>a[i];
		a[i]/=v;
	}
	sort(a+1,a+n+1,cmp);			
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i];			
	}
	cin>>q;
	while(q--){						
		cin>>t;
		if(y+s[n]<=t){
			cout<<-1<<endl;
		}
		else if(y>=t){
			cout<<0<<endl;
		}
		else{
			ans=upper_bound(s+1,s+n+1,t-y)-s;		
			cout<<ans<<endl;
		}
	}
	return 0;
}
2020/5/1 20:43
加载中...