写了个一眼假的贪心就过了
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 105;
int n, m, sum = 0, ans = 0;
struct node{
int v, w;
}a[N];
bool cmp (node x, node y){
return x.w > y.w;
}
signed main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i) cin >> a[i].v >> a[i].w;
sort (a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; ++i){
sum += a[i].v;
if (sum > m) break;
ans += a[i].w;
}
cout << ans << '\n';
return 0;
}