#include <bits/stdc++.h>
using namespace std;
const int INF = -1e9;
int maximumTotalWeight(int k, int n, int m, vector<pair<int,int>>& clusters) {
// Initialize the dp array with size [k+1][n+1][m+1]
// dp[i][x][y] represents the maximum total weight when considering the first i clusters,
// with x elements chosen for group 1 and y elements chosen for group 2
vector<vector<vector<int>>> dp(k+1, vector<vector<int>>(n+1, vector<int>(m + 1, INF)));
dp[0][0][0] = 0; // Base case: no clusters considered, no elements chosen, total weight is 0
// Iterate through all clusters
for(int i = 1; i <= k; i++) {
int weightOfFirstGroup = clusters[i - 1].first;
int weightOfSecondGroup = clusters[i - 1].second;
for(int x = 0; x <= n; x++) {
for(int y = 0; y <= m; y++) {
// Case 1: Do not choose this cluster
dp[i][x][y] = dp[i-1][x][y];
// Case 2: Choose this cluster for group 1
if(x > 0) {
dp[i][x][y] = max(dp[i][x][y], dp[i-1][x-1][y] + weightOfFirstGroup);
}
// Case 3: Choose this cluster for group 2
if(y > 0) {
dp[i][x][y] = max(dp[i][x][y], dp[i-1][x][y-1] + weightOfSecondGroup);
}
}
}
}
return dp[k][n][m];
}
int main() {
int k, n, m; cin >> k >> n >> m;
vector<pair<int,int>> clusters(k);
for(auto& x : clusters) cin >> x.first >> x.second;
cout << maximumTotalWeight(k, n, m, clusters);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgSU5GID0gLTFlOTsKaW50IG1heGltdW1Ub3RhbFdlaWdodChpbnQgaywgaW50IG4sIGludCBtLCB2ZWN0b3I8cGFpcjxpbnQsaW50Pj4mIGNsdXN0ZXJzKSB7CiAgICAvLyBJbml0aWFsaXplIHRoZSBkcCBhcnJheSB3aXRoIHNpemUgW2srMV1bbisxXVttKzFdCiAgICAvLyBkcFtpXVt4XVt5XSByZXByZXNlbnRzIHRoZSBtYXhpbXVtIHRvdGFsIHdlaWdodCB3aGVuIGNvbnNpZGVyaW5nIHRoZSBmaXJzdCB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ICB9CgogICAgICAgICAgICAgICAgLy8gQ2FzZSAzOiBDaG9vc2UgdGhpcyBjbHVzdGVyIGZvciBncm91cCAyCiAgICAgICAgICAgICAgICBpZih5ID4gMCkgewogICAgICAgICAgICAgICAgICAgIGRwW2ldW3hdW3ldID0gbWF4KGRwW2ldW3hdW3ldLCBkcFtpLTFdW3hdW3ktMV0gKyB3ZWlnaHRPZlNlY29uZEdyb3VwKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gZHBba11bbl1bbV07Cn0KCmludCBtYWluKCkgewoJaW50IGssIG4sIG07IGNpbiA+PiBrID4+IG4gPj4gbTsKCXZlY3RvcjxwYWlyPGludCxpbnQ+PiBjbHVzdGVycyhrKTsKCWZvcihhdXRvJiB4IDogY2x1c3RlcnMpIGNpbiA+PiB4LmZpcnN0ID4+IHguc2Vjb25kOwoJCgljb3V0IDw8IG1heGltdW1Ub3RhbFdlaWdodChrLCBuLCBtLCBjbHVzdGVycyk7CgkKCXJldHVybiAwOwp9