#K37357. Identify Malfunctioning Sensors

    ID: 25958 Type: Default 1000ms 256MiB

Identify Malfunctioning Sensors

Identify Malfunctioning Sensors

In this problem, you are given a series of sensor readings. Each reading consists of a sensor ID, a timestamp, and a temperature value. Your task is to detect sensors that are malfunctioning. A sensor is considered malfunctioning if the absolute difference between its current temperature reading and its previous temperature reading exceeds (15) degrees (i.e., (|T_i - T_{i-1}| > 15)).

The input is provided via standard input. The first line contains an integer (n) denoting the number of readings. This is followed by (n) lines, and each line contains three values separated by spaces: the sensor id (a string), the timestamp (a string, which can be ignored during processing), and the temperature (an integer).

Your program should check the readings in the order they are given. For each sensor, if any consecutive readings differ by more than (15), mark that sensor as malfunctioning. In the output (to standard output), you should print the malfunctioning sensor IDs in lexicographical (ascending) order separated by spaces. If no sensor is malfunctioning, print a single 0.

Note: Ensure your solution reads from standard input and writes to standard output.

inputFormat

The first line contains an integer (n), representing the number of sensor readings. The following (n) lines each contain a sensor reading with three space-separated values: a sensor ID (string), a timestamp (string), and a temperature (integer).

outputFormat

Output the malfunctioning sensor IDs sorted in lexicographical order on a single line separated by spaces. If there are no malfunctioning sensors, output a single 0.## sample

3
sensor_1 2023-01-01T01:00:00Z 22
sensor_1 2023-01-01T02:00:00Z 25
sensor_1 2023-01-01T03:00:00Z 20
0