#include using namespace std; int N, B; int X[500], Y[500], P[500]; int id[500]; int Xs[500], Ps[500], Cs[500]; bool comp(int i, int j){ return (X[i] < X[j]); } int main(){ cin >> N >> B; for(int i=0;i> X[i] >> Y[i] >> P[i]; id[i] = i; } sort(id, id + N, comp); int res = 0; for(int i=0;i B){ psum -= Ps[p]; csum -= Cs[p]; ++p; } res = max(res, csum); } } cout << res << endl; return 0; }