#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
int t,c=0;
cin>>t;
while(t--){
int n,k,b,t;
cin>>n>>k>>b>>t;
int x[50],v[50];
for(int i=0;i<n;i++)
cin>>x[i];
for(int i=0;i<n;i++)
cin>>v[i];
int positives=0,negatives=0,ans=0;
for(int i=n-1;i>=0;i--){
int dist=b-x[i];
int time=(dist+v[i]-1)/v[i];
if(time<=t)positives++,ans+=negatives;
else negatives++;
if(positives==k)break;
}
cout<<"Case #"<<++c<<": ";
if(positives==k)cout<<ans<<'\n';
else cout<<"IMPOSSIBLE"<<'\n';
}
return 0;
}
Comments
Post a Comment