A coastal research network operates a chain of drifting ocean buoys. Every buoy periodically radios back a temperature reading, and the same buoy can appear many times in the log as it keeps reporting. The monitoring desk wants to know how many distinct buoys have ever triggered a heat alert, where a heat alert is triggered by any single reading that is strictly greater than a given threshold T.
Given the full log of readings and the threshold T, report the number of distinct buoy IDs that produced at least one reading strictly greater than T.
The first line contains two integers n and T — the number of readings in the log and the alert threshold.
Each of the next n lines contains two integers buoyId and temperature, describing one reading. The same buoyId may appear on multiple lines.
Print a single integer: the number of distinct buoy IDs that have at least one reading strictly greater than T.
Example 1
Input
5 30 1 25 2 35 1 40 3 10 2 20
Expected
2
Explanation
Buoy 1 reports 25 and 40; 40 > 30 so buoy 1 triggers an alert. Buoy 2 reports 35 and 20; 35 > 30 so buoy 2 also triggers an alert. Buoy 3 only reports 10, which never exceeds 30. Two distinct buoys (1 and 2) triggered an alert, so the answer is 2.
Example 2
Input
4 -5 10 -10 10 -3 20 -6 30 -5
Expected
1
Explanation
Buoy 10 reports -10 and -3; -3 > -5 so it triggers an alert. Buoy 20 reports only -6, which is not greater than -5. Buoy 30 reports exactly -5, which is not strictly greater than -5. Only buoy 10 qualifies, so the answer is 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 →