Official algorithmic problem description and constraints.
Timur is in a car traveling on the number line from point 0 to point π. The car starts moving from point 0 at minute 0.
There are π+1 signs on the line at points 0,π1,π2,β¦,ππ, and Timur knows that the car will arrive there at minutes 0,π1,π2,β¦,ππ, respectively. The sequences π and π are strictly increasing with ππ=π.

Between any two adjacent signs, the car travels with a constant speed. Timur has π queries: each query will be an integer π, and Timur wants you to output how many minutes it takes the car to reach point π, rounded down to the nearest integer.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.