//Fractional Knapsack 
#include <bits/stdc++.h>
using namespace std;

struct Item {
    int value, weight;
};

bool cmp(Item a, Item b) {
    return (double)a.value/a.weight > (double)b.value/b.weight;
}

int main() {
    vector<Item> arr = {{60,10},{100,20},{120,30}};
    int W = 50;

    sort(arr.begin(), arr.end(), cmp);

    double total = 0;

    for (int i = 0; i < arr.size(); i++) {
        if (W >= arr[i].weight) {
            W -= arr[i].weight;
            total += arr[i].value;
        } else {
            total += (double)arr[i].value * W / arr[i].weight;
            break;
        }
    }

    cout << "Maximum value: " << total << endl;
}