Pagini recente » Cod sursa (job #476008) | Cod sursa (job #949447) | Cod sursa (job #556827) | Cod sursa (job #1651572) | Cod sursa (job #1916581)
#include <bits/stdc++.h>
#define nmax 1005
using namespace std;
int g[nmax],n,v[nmax],gmax;
struct Dublu
{
double greutate;
int val;
};
Dublu t[nmax];
inline bool Sortare(const Dublu A,const Dublu B)
{
return A.val*B.greutate>A.greutate*B.val;
}
void Citire()
{
int i;
cin>>n>>gmax;
for(i=1;i<=n;i++)
cin>>t[i].greutate>>t[i].val;
sort(t+1,t+n+1,Sortare);
}
void Rezolvare()
{
int i;
double sol=0;
for(i=1;i<=n && gmax>=t[i].greutate;i++)
{
gmax-=t[i].greutate;
sol+=t[i].val;
}
if(i<=n)
sol+=(double)(gmax*t[i].val)/t[i].greutate;
cout<<setprecision(3)<<fixed<<sol<<"\n";
}
int main()
{
Citire();
Rezolvare();
return 0;
}