#K12571. Detect Abnormal Sensor Temperature Changes

    ID: 23720 Type: Default 1000ms 256MiB

Detect Abnormal Sensor Temperature Changes

Detect Abnormal Sensor Temperature Changes

You are given a series of sensor readings where each reading consists of a sensor ID and a temperature value. Your task is to detect all sensors that have reported an abnormal temperature change. An abnormal change for a sensor is defined as a temperature difference that exceeds a given threshold between two consecutive readings (considering only the most recent reading due to a sliding window of a fixed size).

The input provides a total number of readings n, a threshold value τ (in LaTeX: \(\tau\)) which is the maximum allowed difference, and a time interval T which determines how many recent readings are kept for each sensor. For each sensor, if the absolute difference between the current reading and its immediate previous reading (within the sliding window) exceeds \(\tau\), then the sensor is flagged as abnormal.

Note that even if a sensor has multiple abnormal readings, it should be reported only once. In the end, output the sensor IDs that exhibited an abnormal change in ascending order, separated by a single space. If no sensor exhibits an abnormal change, output an empty line.

inputFormat

The first line of the input contains three values separated by spaces:

  • n: the number of readings (an integer)
  • threshold: the maximum allowed temperature change (a floating-point number, denoted as \(\tau\))
  • time_interval: the number of recent readings to consider for each sensor (an integer, denoted as \(T\))

This is followed by n lines. Each line contains two values:

  • sensor_id: an integer representing the sensor's ID
  • reading: a floating-point number representing the temperature reading

All values are space-separated.

outputFormat

Print the sensor IDs that reported an abnormal temperature change in ascending order, separated by a single space. If no sensor exhibits an abnormal change, output an empty line.

## sample
6 5.0 3
1 20.0
2 22.0
1 30.0
1 20.0
2 28.0
2 22.0
1 2

</p>