Problem link: http://www.spoj.com/problems/ADACABAA/
If there were only only 2 attributes of the vegetables I would have been able to solve the problem. I would have simply sorted in descending order the vegetables according to it's first attribute. And as for the second attribute I could have easily found the answer using a BIT/Fenwick. But I am not able to figure how to solve this problem with 4 attributes of the vegetables. Any help is really appreciated.