UVa 907 - Winterim Backpacking Trip

907 - Winterim Backpacking Trip
http://uva.onlinejudge.org/external/9/907.html

Summary
Given the distances between N consecutive campsites of a trail and given the number of nights for your trip, K, your task is to devise a camping strategy for the specified trail such that it minimises the maximum amount of walking done in a single day. Note that the first distance value given is the distance from our start-point of the trail to our 1st campsite, and the last distance value given is the distance from our Nth campsite to our end-point of the trail.

Explanation
Use binary search to "guess" the minimum of maximum distance. If the number of camp is less than or egual to K, keep lowering the maximum distance needed. Otherwise, increase it.

Input
4 1 7 2 6 4 5 4 2 7 2 6 4 5 4 3 7 2 6 4 5 4 10 7 2 6 4 5

Output
15 9 8 7