奇奇怪怪的0分
查看原帖
奇奇怪怪的0分
895690
gghack_Nythix楼主2022/12/15 10:56
#include <bits/stdc++.h>
using namespace std;
long long a[100000005],b[100000005];
bool cmp(int x, int y)
{
	return x > y;
}
int main()
{
	long long n,l,v,sum = 0;
	cin >> n >> l >> v;
	for(int i = 1;i <= n;i ++)
	{
		cin >> a[i];
	}
	sort(a + 1,a + n + 1,cmp);
	for(int i = 1;i <= n;i ++)
	{
		b[i] = a[i] + b[i - 1];
	}
	int q;
	cin >> q;
	for(int i = 1;i <= q;i ++)
	{
		int x;
		cin >> x;
		x = x * v - l;
		if(x < 0)
		{
			cout << 0 << endl;
		}
		else if(b[n] > x)
		{
			int ans = upper_bound(b + 1,b + n + 1,x) - b;
			cout << ans << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
	return 0;
}
2022/12/15 10:56
加载中...