A profiler collects n latency samples. Given a threshold p, classify every sample into one of three bands: below p, exactly p, or above p. Report the size of each band.
This is the classic three-way (Dutch national flag) partition: conceptually the samples are rearranged into [below | equal | above], and you output the three band sizes.
Line 1: two integers n and p.
Line 2: n space-separated integers, the samples.
Three space-separated integers on one line: the count of samples below p, equal to p, and above p, in that order.
Example 1
Input
6 5 5 2 8 5 1 9
Expected
2 2 2
Explanation
Below 5: {2,1} = 2. Equal to 5: {5,5} = 2. Above 5: {8,9} = 2. Output: 2 2 2.
Example 2
Input
4 0 -1 -2 3 0
Expected
2 1 1
Explanation
Below 0: {-1,-2} = 2. Equal to 0: {0} = 1. Above 0: {3} = 1. Output: 2 1 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →