Time limit
2s
Memory limit
128 MB
There are N sharks. For each shark, three numbers describe its size, speed, and intelligence.
Shark A can eat shark B if A's size, speed, and intelligence are each greater than or equal to B's corresponding values. To prevent too many sharks from disappearing, each shark may eat at most two other sharks.
Only one eating action happens at a time. A shark that has already been eaten cannot eat another shark later.
Given the size, speed, and intelligence of all N sharks, find the minimum possible number of sharks that can survive.
The first line contains the number of sharks N. N is a positive integer not greater than 50.
Each of the next N lines contains three positive integers: the shark's size, speed, and intelligence. Each value is not greater than 2,000,000,000.
Print the minimum possible number of surviving sharks.