CodeForces Technocup 2020 - Elimination Round 1 C
作者:
hongye
,
2025-04-13 13:24:59
· 辽宁
,
所有人可见
,
阅读 1
https:
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 200010;
LL val[N];
LL n , m , k , a , b , x , y;
LL check(int mid){
priority_queue<int> pq;
LL res = 0;
for(int i=1;i<=mid;i++){
if(i%a==0 && i%b==0){
pq.push(x+y);
}else if(i%a==0){
pq.push(x);
}else if(i%b == 0){
pq.push(y);
}
}
int cnt = n;
while(!pq.empty()){
res += (val[cnt--])*pq.top();
pq.pop();
}
return res >= k;
}
int find(){
int l = 1 , r = n+1;
int res = n+1;
while(l<=r){
int mid = (l+r)>>1;
if(check(mid)){
r = mid-1;
res = mid;
}else{
l = mid+1;
}
}
return res;
}
void solve(){
scanf("%lld",&n);
for(int i=1;i<=n;i++){
scanf("%lld",val+i);
val[i]/=100;
}
scanf("%lld%lld",&x,&a);
scanf("%lld%lld",&y,&b);
scanf("%lld",&k);
sort(val+1,val+n+1);
LL ans = find();
if(ans != n+1){
printf("%lld",ans);
}else{
printf("-1");
}
printf("\n");
}
int main(){
int t;
cin>>t;
while(t--) solve();
return 0;
}