#include using namespace std; #define MAX 0x3f3f3f3f #define MIN -0x3f3f3f3f #define ll long long bitset < 1000000 > bs; struct details { int lat, loo, hei, pt; }; details dt[100000]; ll solve(int cur_city, int n, int x, int y) { //if(cur_city == n) return 0; ll ans = 0; for(int i = 0; i < n; i++) { if(bs[i] == 0 and dt[i].hei > dt[cur_city].hei and abs(dt[i].lat - dt[cur_city].lat) <= x and abs(dt[i].loo - dt[cur_city].loo) <= y) { bs[cur_city] = 1; ans = max(ans, solve(i, n, x, y) + dt[cur_city].pt); bs[cur_city] = 0; } } return ans; } int main(){ int n; int x; int y; cin >> n >> x >> y; bs.reset(); for(int i = 0; i < n; i++){ int latitude; int longitude; int height; int points; cin >> latitude >> longitude >> height >> points; dt[i].lat = latitude; dt[i].loo = longitude; dt[i].hei = height; dt[i].pt = points; // your code goes here } vector < vector < details > > fert; for(int i = 0; i < (1 << n); i++) { vector < details > cur; for(int j = 0; j < n; j++) { if(i & (1 << j)) { cur.push_back(dt[j]); } } fert.push_back(cur); } int ans = INT_MIN; for(int i = 0; i < fert.size(); i++) { int cur_ans = 0; for(int j = 0; j < fert[i].size(); j++) { if(j == 0 or (dt[j].hei > dt[j - 1].hei and abs(dt[j - 1].lat - dt[j].lat) <= x and abs(dt[j - 1].loo - dt[j].loo) <= y)) { cur_ans += dt[j].pt; } } ans = max(ans, cur_ans); } cout << ans << "\n"; return 0; }