#C10320. Maximum Number of Valid Groups

    ID: 39513 Type: Default 1000ms 256MiB

Maximum Number of Valid Groups

Maximum Number of Valid Groups

Given a list of student heights, your task is to form as many valid groups of 3 students as possible such that the heights in every group are non-decreasing. In other words, once the list is sorted, every set of three consecutive heights forms a valid group. The answer is simply the maximum number of groups you can form, which is (\lfloor \frac{n}{3} \rfloor), where (n) is the total number of students. This is because, after sorting, any three consecutive elements are automatically in non-decreasing order.

inputFormat

The first line contains one integer (n) (the number of students). The second line contains (n) integers representing the heights of the students. (n) and the heights are separated by spaces.

outputFormat

Output a single integer denoting the maximum number of groups of 3 students that can be formed such that in each group the heights are in non-decreasing order.## sample

6
1 2 3 4 5 6
2