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: 13ms
Memory: 1716kB
Author: 2018212212175
In contest: 1273

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const double inf = 1e-7;
struct node {
	int zl;
	int jz;
	double dj;
}zz[100];
bool cmp(const node &a,const node &b)
{
	return a.dj > b.dj;
}
int main()
{
	int t;
	int n, m;
	cin >> t;
	while (t--)
	{
		double ans = 0;
		cin >> n >> m;
		for (int i = 1; i <= n; i++)
		{
			cin >> zz[i].zl;
		}
		for (int i = 1; i <= n; i++)
		{
			cin >> zz[i].jz;
		}
		for (int i = 1; i <= n; i++)
		{
			zz[i].dj = 1.0*zz[i].jz / zz[i].zl;
		}
		sort(zz + 1, zz + n + 1, cmp);
		for (int i = 1; i <= n; i++)
		{
			if (zz[i].zl <= m)
			{
				m = m - zz[i].zl;
				ans = ans + zz[i].jz;
			}
			else
			{
				ans = ans + 1.0*m*zz[i].dj;
				break;
			}
		}
		printf("%.2f\n", ans + inf);
	}
	return 0;
}