#include #include using namespace std; struct city{ int latitude; int longitude; int height; int points; city(int lat, int lon, int ht, int p):latitude(lat),longitude(lon), height(ht),points(p){} }; struct less_than_key { inline bool operator() (const city& struct1, const city& struct2) { return (struct1.height < struct2.height); } }; int maxSubArraySum(const vector& a) { int max_so_far = INT_MIN, max_ending_here = 0; for (int i = 0; i < a.size(); i++) { max_ending_here = max_ending_here + a[i]; if (max_so_far < max_ending_here) max_so_far = max_ending_here; if (max_ending_here < 0) max_ending_here = 0; } return max_so_far; } int main(){ int n; int x; int y; vector cities; cin >> n >> x >> y; for(int a0 = 0; a0 < n; a0++){ int latitude; int longitude; int height; int points; cin >> latitude >> longitude >> height >> points; cities.push_back(city(latitude, longitude, height, points) ); } sort(begin(cities),end(cities),less_than_key() ); vector pointVec; for(auto iter: cities){ //cerr << "height: " << iter.height << endl; pointVec.push_back(iter.points); } cout << maxSubArraySum(pointVec); return 0; }