← All problemsSign in

Two Trains

CodeChefRating 1230Open on judge ↗

There are $2$ trains $A$ and $B$ and $N$ stations in a line from $1$ to $N$ in order. There is also an array $P$ of length $N-1$ such that $P_i$ $(1\le i \lt N)$ denotes the amount of time any train takes to go from the $i$-th station to the $(i+1)$-th station. Initially, both trains are at station $1$. Train $A$ departs from station $1$ and stops directly at station $N$. For safety purposes, it

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start