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

struct max_value{
    int value;
    int weight;
    double ratio;
};

bool compare(max_value &a,max_value &b){
    return a.ratio>b.ratio;
};

int main(){
    int n;
    vector<max_value> obj(n);
    for(int i=0;i<n;i++){
        cin>>obj[i].value>>obj[i].weight;
        obj[i].ratio=(double)(obj[i].value/obj[i].weight);

    }
    int total_weight;
    cin>>total_weight;
    int temp = total_weight;
    
    cout<<"values:";
    for(int i=0;i<n;i++){
        cout<<obj[i].value;
    }
    cout<<endl;
    
    cout<<"weight: ";
    for(int i=0;i<n;i++){
        cout<<obj[i].weight;
    }
    cout<<endl;
    sort(obj[i].begin,obj[i].end,compare);
    double large=0;
    double  total_weight=0;
    for(int i=0;i<n;i++){
        if(total_weight==0) break;
        if(obj[i].weight<=total_weight){
            total_weight+=obj[i].weight;
            large+=obj[i].value;
            toal_weight-=obi[i].weight;
        }
        else{
            total_weight+=total_weight;
            large = total_weight*obj[i].weight;
            total_weight=0;
        }
        
        
        
    }
    cout<<fixed<<setprecision(2);
    
    cout<<"Total weight in the bag "<<total_weight;
    
    cout<<endl;
    
    
    cout<<"max value for "<<temp<<"weight is "<<fixed<<setprecision(2)<<large;
    cout<<endl;
    
    
}