Pagini recente » Cod sursa (job #1241161) | Cod sursa (job #912503) | Cod sursa (job #1962396) | Istoria paginii runda/matrice_/clasament | 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;
}