条件付き最適化問題

最近トップコーダーの2部千点の問いを考えています。四つの島と三つの川を渡るのが問題です。歩きと泳ぎの速度を含めて最速の道を出力しなければいけません。島は全て同じな長さでゼロと同じな広さであります。歩く場合に単に縦方向の動きになります。泳ぐ場合に横方向と縦方向になります。It seems that a key point is, discounting all walking, to determine how much swimming should be done in a vertical direction at each river (as the horizontal span of the river must be crossed no matter what). If the walking rate is greater than the swimming rate, then the gradient of the time function with respect to the vertical components of the swim vectors can be computed and set equal to zero, allowing these vertical components to be solved for. However, if the walking rate is less than the swimming rate, then this expression is not a real number (the denominator becomes the square root of a negative number).