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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#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);
	} 
}