Pagini recente » Cod sursa (job #1936324) | Cod sursa (job #392303) | Cod sursa (job #2080758) | Cod sursa (job #2457980) | Cod sursa (job #3247154)
#include <iostream>
#include <algorithm>
using namespace std;
pair<pair<double, int>, int> obiecte[1000];
int n, gm;
double V;
int main() {
cin >> n >> gm;
for(int i = 0; i < n; i++) {
cin >> obiecte[i].first.second >> obiecte[i].second;
obiecte[i].first.first = 1.00 * obiecte[i].second / obiecte[i].first.second;
}
sort(obiecte, obiecte + n);
for(int i = n - 1; i >= 0; i--) {
if(gm - obiecte[i].first.second < 0) {
V += (double)gm / obiecte[i].first.second * obiecte[i].second;
break;
} else {
V += obiecte[i].second;
gm -= obiecte[i].first.second;
}
}
cout << V;
}