1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| #include<bits/stdc++.h> #define x first #define y second #define ok cout << "ok" << endl; using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const double PI = acos(-1.0); const int INF=0x3f3f3f3f; const ll LINF=0x3f3f3f3f3f3f3f3f; const int N=2e5+9; const int shift=1e3+9; const double Eps=1e-7;
ll n, aa, b, t, ans, sum;
struct node { ll hea, dam; }a[N];
bool cmp(node a, node b) { return (a.hea - a.dam) > (b.hea - b.dam); }
int main(void) { if(fopen("in", "r")!=NULL) {freopen("in", "r", stdin); freopen("out", "w", stdout);} while(cin >> n >> aa >> b) { t = 1; while(aa--) t *= 2; for(int i = 0; i < n; i++) scanf("%lld%lld", &a[i].hea, &a[i].dam); sort(a, a + n, cmp); for(int i = 0; i < n; i++) { if(i < b) sum += max(a[i].hea, a[i].dam); else sum += a[i].dam; } if(b == 0) { printf("%lld\n", sum); continue; } for(int i = 0; i < n; i++) { if(i < b) ans = max(ans, sum - max(a[i].hea, a[i].dam) + max(a[i].hea * t, a[i].dam)); else ans = max(ans, sum - max(a[b-1].hea, a[b-1].dam) + a[b-1].dam - a[i].dam + max(a[i].hea * t, a[i].dam)); } printf("%lld\n", ans); }
return 0; }
|