#P15315. [VKOSHP 2025] Predicting a Position
[VKOSHP 2025] Predicting a Position
Description
An ascending sorted array of unique integer keys and some integer non-negative constant is given.
It is necessary to split the original key array into a minimum number of sub-arrays, so that on each sub-array there is some linear function , predicting for the key its position on this sub-array --- it is equal to --- with an error not exceeding .
Formally, for the -th of the sub-array, the coefficients and must exist (not necessarily integers) so that for all the keys on that sub-array is true:
Input Format
In the first line of the input data, two integers are separated by a space: , --- the number of keys and the maximum allowable error, respectively (, ).
The second line of input data contains the unique keys separated by a space in ascending order ($-2\cdot 10^9 \le x_1 < x_2 < \ldots < x_n \le 2\cdot 10^9$).
Output Format
In a single line of the output data, print a single integer --- the minimum number of sub-arrays into which you were able to split the original array of keys so as to meet the requirements.
8 0
1 2 3 4 7 10 13 16
2
Hint
In the example, you can split the specified array of keys into two: and . In the first case, the key position is predicted exactly by the function . In the second case, the key position is accurately predicted by the function .
京公网安备 11011102002149号