ENIGMA-0x03 (2025) - S1 The Faulty Sensor
View as PDFThe Faulty Sensor

There is probably no teenager in 2025 who, while working with electronics, has not used the popular HC-SR04 ultrasonic sensor as a distance sensor in one of their projects. They are very easy to use and reliable... generally speaking :-)
In Totos's lab, there are such sensors, but we want to check how reliable they still are, since we remember that there should be at most one faulty sensor.
For this purpose, Totos built an HC-SR04 tester with a screen that displays
consecutive measurements.
To push them to their limits, he also added a regulator
, which defines the maximum acceptable deviation in their measurements - that is, the difference between the maximum and minimum measurement.
At the bottom right, the tester has a large red light that turns on (command
1) when the sensor is faulty, and remains off (command 0) when the sensor is acceptable.
Input Data (STDIN)
On the first line of input, positive integers
and
are given: the number of sensors and the maximum acceptable deviation in their measurements, respectively.
In the next
lines,
single-digit positive integers are given, representing the 10 measurements of each sensor.
Output Data (STDOUT)
The program should print the evaluation of each sensor on separate lines, in the order they were given.
Examples
1st
Input (STDIN)
3 8
5 5 5 5 5 5 5 5 5 5
1 2 3 2 1 2 3 2 1 2
9 0 0 0 9 9 0 0 0 9
Output (STDOUT)
0
0
1
2nd
Input (STDIN)
2 5
4 4 4 4 4 5 5 5 5 5
1 2 3 4 9 3 2 1 2 3
Output (STDOUT)
0
1
Subtasks
- For
of the points:
- For
of the points:
- For
of the points:
Comments