Start: Jun, 26, 2019 08:30:00
2019年度暑期短学期第一天
End: Jun, 26, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 10ms
Memory: 1716kB
Author: 2018212212048
In contest: 1273

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
struct zongzi{
	double a;
	double b;
	double c;
}s[20];
bool CMP(const zongzi &a,const zongzi &b){
	return a.c>b.c;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		double m;
		cin>>n>>m;
		for(int i=1;i<=n;i++){
			cin>>s[i].a;
		} 
		for(int i=1;i<=n;i++){
			cin>>s[i].b;
			s[i].c=s[i].b/s[i].a;
		} 
		sort(s+1,s+1+n,CMP);
		int cnt=1;
		double sum=0;
		while(m>s[cnt].a&&cnt<=n){
			sum+=s[cnt].b;
			m-=s[cnt].a;
			cnt++; 
		}
		if(cnt<=n) sum+=m*s[cnt].c;
		printf("%.2lf\n",sum+1e-7);
	} 
}