2
public int minSkips(int[] dist, int speed, int hoursBefore) {3
int N = dist.length, INF = (int) 1e9;6
dp[0] = 0; // before we start, we have a time of 0 for 0 cost7
for (int i = 0; i < N; i++) {10
j--) { // j (cost) is at most i (num of element-1) so we start from there.11
dp[j] = Math.min(j == 0 ? INF : dp[j - 1] + dist[i], ceil(dp[j], speed) + dist[i]);16
i++) { // find the min cost (i) such that the min time is no greater than hoursBefore17
if (ceil(dp[i], speed) / speed <= hoursBefore) {24
private int ceil(int n, int s) {25
return n + (s - n % s) % s;