#include<bits/stdc++.h>
using namespace std;
struct node
{
int obj;
double pbw;
};
bool comparepbw(node p1, node p2)
{
if(p1.pbw > p2.pbw)
return true;
else return false;
}
int main()
{
int n,m;
cin>>n>>m;
int profit[n];
int weight[n];
for(int i=0; i<n; i++)
{
cin>>profit[i];
}
for(int i=0; i<n; i++)
{
cin>>weight[i];
}
node Pbw[n];
for(int i=0; i<n; i++)
{
Pbw[i].obj=i;
Pbw[i].pbw=double(profit[i])/double(weight[i]);
}
sort(Pbw,Pbw+n,comparepbw);
double x[n];
memset(x, 0, sizeof(x));
double rw=double(m);
for(int i=0; i<n; i++)
{
if(rw>0)
{
if(rw>=weight[Pbw[i].obj] )
{
rw= double(rw)-double(weight[Pbw[i].obj]);
x[Pbw[i].obj]=1;
}
else
{
x[Pbw[i].obj]=double(rw)/double(weight[Pbw[i].obj]);
rw=0;
}
}
}
double maxpf=0;
for(int i=0; i<n; i++)
{
maxpf=maxpf+x[i]*double(profit[i]);
}
cout<<"Maximum Profit :"<<maxpf<<endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3Qgbm9kZQp7CgogICAgaW50IG9iajsKICAgIGRvdWJsZSBwYnc7CgoKfTsKCmJvb2wgY29tcGFyZXBidyhub2RlIHAxLCBub2RlIHAyKQp7CiAgICBpZihwMS5wYncgPiBwMi5wYncpCiAgICAgICAgcmV0dXJuIHRydWU7CiAgICBlbHNlIHJldHVybiBmYWxzZTsKfQoKCmludCBtYWluKCkKewogICAgaW50IG4sbTsKICAgIGNpbj4+bj4+bTsKICAgIGludCBwcm9maXRbbl07CiAgICBpbnQgd2VpZ2h0W25dOwoKCiAgICBmb3IoaW50IGk9MDsgaTxuOyBpKyspCiAgICB7CiAgICAgICAgY2luPj5wcm9maXRbaV07CiAgICB9CiAgICBmb3IoaW50IGk9MDsgaTxuOyBpKyspCiAgICB7CiAgICAgICAgY2luPj53ZWlnaHRbaV07CiAgICB9CgogICAgbm9kZSBQYndbbl07CgogICAgZm9yKGludCBpPTA7IGk8bjsgaSsrKQogICAgewogICAgICAgIFBid1tpXS5vYmo9aTsKICAgICAgICBQYndbaV0ucGJ3PWRvdWJsZShwcm9maXRbaV0pL2RvdWJsZSh3ZWlnaHRbaV0pOwogICAgfQogICAgc29ydChQYncsUGJ3K24sY29tcGFyZXBidyk7CgogICAgZG91YmxlIHhbbl07CiAgICBtZW1zZXQoeCwgMCwgc2l6ZW9mKHgpKTsKCiAgICBkb3VibGUgcnc9ZG91YmxlKG0pOwogICAgZm9yKGludCBpPTA7IGk8bjsgaSsrKQogICAgewogICAgICAgIGlmKHJ3PjApCiAgICAgICAgewogICAgICAgICAgICBpZihydz49d2VpZ2h0W1Bid1tpXS5vYmpdICkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcnc9IGRvdWJsZShydyktZG91YmxlKHdlaWdodFtQYndbaV0ub2JqXSk7CiAgICAgICAgICAgICAgICB4W1Bid1tpXS5vYmpdPTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB4W1Bid1tpXS5vYmpdPWRvdWJsZShydykvZG91YmxlKHdlaWdodFtQYndbaV0ub2JqXSk7CiAgICAgICAgICAgICAgICBydz0wOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgZG91YmxlIG1heHBmPTA7CiAgICBmb3IoaW50IGk9MDsgaTxuOyBpKyspCiAgICB7CiAgICAgICAgbWF4cGY9bWF4cGYreFtpXSpkb3VibGUocHJvZml0W2ldKTsKICAgIH0KICAgIGNvdXQ8PCJNYXhpbXVtIFByb2ZpdCA6Ijw8bWF4cGY8PGVuZGw7CgoKfQo=