LCC '21 Contest 3 S1 - Meow

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Authors:
Problem type

Alan is planning to adopt a cat!

In front of him is a line of N cats. Alan is selecting a cat based on 3 categories: cuteness a_i, cleanliness b_i, and coolness c_i. A cat x is considered an alpha cat if there exists no cat y with a_y > a_x, b_y > b_x, and c_y > c_x. In other words, cat x is alpha if no other cat outperforms cat x in every category.

For example, consider a cat with values [5, 2, 8] and a different cat with values [3, 2, 5]. The first cat does not outperform the second cat in every category, since their b_i is equal. Next, consider a cat with values [5, 4, 8] and a different cat with values [3, 2, 5]. The first cat outperforms the second cat in every category.

Help Alan find the number of alpha cats!

Input Specification

The first line will contain one integer N (1 \leq N \leq 10^3), the number of cats.

Each of the next N lines will contain 3 space-separated integers, a_i (0 \leq a_i \leq 10^9) , b_i (0 \leq b_i \leq 10^9), and c_i (0 \leq c_i \leq 10^9).

Output Specification

Output the number of alpha cats.

Sample Input

4
3 3 4
2 2 4
9 1 3
2 2 3

Sample Output

3

Explanation

All cats are alpha cats except for the last cat. The first cat outperforms the last cat in every category.


Comments

There are no comments at the moment.