**Problem Link:** E - Train

**Doubt:** In this problem the edge weight (the effective time to **reach** the neighboring node) depends on the time at which we arrived at the current node as we can leave the other node only at particular intervals, so we have to spend some time waiting until that moment when the trains leaves. To calculate the effective time to travel from A to B, I used the following inequality, T+T_{i}\leq mK_{i}, where T is the arrival time at node A, T_{i} is the time taken to travel that edge and K_{i} is the interval at which a train leaves both from A and B. We just have to find the smallest integral value of m that satisfies the given inequality, and our effective time will then be mK_{i}. So I set m as \lceil{\frac{T+T_{i}}{K_{i}}}\rceil which gives the effective time as \lceil{\frac{T+T_{i}}{K_{i}}}\rceil K_{i}, but it turns out that this is incorrect . I checked the editorial and there they have given the formula for the effective time as \lceil{\frac{T}{K_{i}}}\rceil K_{i}+T_{i}, and this where I am stuck. How did they arrive at this formula and why is my formula wrong? Can anyone help?