#include <iostream>
#include <algorithm>
using namespace std;
struct foun {
int b,p;
char c;
bool operator < (const foun& y) {
return b > y.b;
}
} a[100005];
int main() {
int n,c,d; cin >> n >> c >> d;
for(int i = 1;i <= n;i++) cin >> a[i].b >> a[i].p >> a[i].c;
sort(a+1,a+n+1);
int cnt = 0,ans = 0;
for(int i = 1;i <= n;i++) {
if(cnt == 2) break;
if(a[i].c == 'C') {
if(c >= a[i].p) {
c -= a[i].p; //Arkady can buy it
ans += a[i].b;
cnt++;
}
}
else {
if(d >= a[i].p) {
d -= a[i].p; //Arkady can buy it
ans += a[i].b;
cnt++;
}
}
}
if(cnt == 2) cout << ans << endl;
else cout << 0 << endl;
return 0;
}
rt,思路就是按美丽值从大到小排序,能买就买,样例全过,但是不知道哪错了,求问。或者有大佬能给出 hack 的也行。