Gasoline
CodeChefOpen on judge ↗
For an array $A$ of size $N$, and an integer $K$, define $f(A, K)$ in the following way: - You start in city $1$ on a one-dimensional plane with $N + 1$ cities, numbered $1$ to $N + 1$ linearly. The $i$-th ($1 \le i \le N$) city allows you to refuel $1$ litre of petrol for $A_i$ cost. - You want to travel from city $1$ to $N + 1$ in the order $1, 2, \ldots, N + 1$. - Initially you have an
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start