ENIGMA-0x03 (2025) - S1 The Faulty Sensor

View as PDF

Submit solution

Points: 100 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
Blockly, C, C++, Java, Pascal, Python

The 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 N 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 10 consecutive measurements. To push them to their limits, he also added a regulator K, 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, 2 positive integers N and K are given: the number of sensors and the maximum acceptable deviation in their measurements, respectively. In the next N lines, 10 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 N 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 30\% of the points: N = 1
  • For 60\% of the points: 1 \le N \le 2
  • For 100\% of the points: 1 \le N \le 10

Comments

There are no comments at the moment.