Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- long long n,f;
- cin >> n >> f;
- vector<pair<long long,long long>> v;
- for(long long i=0;i<n;i++)
- {
- long long a,b;
- cin >> a >> b;
- v.push_back(make_pair(a,b));
- }
- sort(v.begin(),v.end());
- for(long long i=n-1;i>=0;i--)
- {
- if(f>0 and v[i].second>0)
- {
- v[i].first*=2;
- f--;
- }
- }
- long long count=0;
- for(long long i=0;i<n;i++)
- {
- count+=min(v[i].first,v[i].second);
- }
- cout << count;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement