#include #include using std::vector; double get_optimal_value(int capacity, vector weights, vector values) { double value = 0.0; while ((capacity > 0) && (weights.size() > 0)) { int idx = 0; double ratio = 0.0; for (int i = 0; i < weights.size(); i++) { double r = ((double) values.at(i)) / weights.at(i); if (r > ratio) { idx = i; ratio = r; } } double a = capacity; if (weights[idx] < capacity) a = weights[idx]; value += (ratio * a); capacity -= a; weights.erase(weights.begin()+idx); values.erase(values.begin()+idx); } return value; } int main() { int n; int capacity; std::cin >> n >> capacity; vector values(n); vector weights(n); for (int i = 0; i < n; i++) { std::cin >> values[i] >> weights[i]; } double optimal_value = get_optimal_value(capacity, weights, values); std::cout.precision(10); std::cout << optimal_value << std::endl; return 0; }