Skip to content

Commit

Permalink
Add 32196.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Aug 28, 2024
1 parent 4962ae9 commit 1d37f18
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 32xxx/32196.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int n, m;
long long k, x, y;

bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
return x * a.first - y * a.second < x * b.first - y * b.second;
}

void solve(void) {
cin >> n >> m >> k >> x >> y;
vector<pair<int, int>> v(n);
for (int i=0; i<n; i++) cin >> v[i].first >> v[i].second;
sort(v.begin(), v.end(), cmp);

long long a = 0, b = 0;
for (int i=0; i<m; i++) {
a += v[i].first; b += v[i].second;
}
cout << (k + a) * x + (k - b) * y;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

solve();
return 0;
}

0 comments on commit 1d37f18

Please sign in to comment.