Sponsors

Tag: problem: (B) Summer sell-off Solve In C/C++

Codeforces Round #415 (Div....

#include<bits/stdc++.h> using namespace std; int64_t n,f,k,l,i,w,s,a; int main(){ for(cin>>n>>f;i<n;i++)cin>>k>>l,w=min(k,l),a=min(2*k,l)-w,s+=w; sort(a,a+n); for(i=0;i<n;i++)s+=i<f?a:0; cout<<s; }

Advertisement

spot_img