| 11 | } |
| 12 | |
| 13 | int main() |
| 14 | { |
| 15 | int n; |
| 16 | cin>>n; |
| 17 | |
| 18 | vector<pair<int,int>> v(n); |
| 19 | |
| 20 | for(int i=0;i<n;i++) |
| 21 | { |
| 22 | cin>>v[i].first>>v[i].second; |
| 23 | } |
| 24 | |
| 25 | int w; |
| 26 | cin>>w; |
| 27 | |
| 28 | sort(v.begin(),v.end(),compare); |
| 29 | |
| 30 | int ans=0; |
| 31 | |
| 32 | for(int i=0;i<n;i++) |
| 33 | { |
| 34 | if(w>=v[i].second) |
| 35 | { |
| 36 | ans+=v[i].first; |
| 37 | w-=v[i].second; |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | double vw=((double)v[i].first/v[i].second); |
| 42 | ans+= vw*w; |
| 43 | w=0; |
| 44 | break; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | cout<<ans<<endl; |
| 49 | |
| 50 | } |
nothing calls this directly
no outgoing calls
no test coverage detected