Algorithm to determine minimum server required? So I came across a problem that has be completely stumped. You're given n servers to store a file on and you need to find the minimum number of servers you need to store the file on so that you can minimize the cost of the client and to the user.

When the user tries to look for a file he will start at some unknown server, check to see if the file is there and if it's not will move on to the next server and do the same. The cost is the minimum distance between the user and the server with the file.

To upload the file to the i'th server it would cost the client c_i

The exception is that you can upload it to the n'th server for a cost of 0 (meaning that the user will never have to loop around and the worst case won't be n)

So basically I need to find an algorithm that will find a subset that will give us a balance between the cost to the client and the cost to the user.
This answer assumes that what you're trying to minimize is
$$
 \sum_{i \in S} c_i + \sum_{i=1}^n d(i,S),
$$
where $c_i$ is the cost of the $i$th server and 
$$d(i,S) = \min_{\substack{j \in S \\ j \geq i}} \; j-i$$
is the distance from $i$ to the closest server.

Use dynamic programming. For all $j \leq j_0$, compute the minimum of
$$
 \sum_{i \in S} c_i + \sum_{i=j}^n d(j,S)
$$
over all $S \subseteq \{j,\ldots,n\}$ such that $\min S = j_0$.