1) { $dp[$i] = min($dp[$i], $dp[$i - 2] + $B[$i - 2]); } } return $dp[$N - 1]; } $input = explode("\n", trim(file_get_contents("php://stdin"))); $N = (int)$input[0]; $A = array_map('intval', explode(" ", $input[1])); $B = isset($input[2]) ? array_map('intval', explode(" ", $input[2])) : []; echo minTimeToReachN($N, $A, $B) . "\n";