← 返回 amazon 的题目列表Synchronization of Data across Servers
类型:online_judge
Given n servers that transmit data to each other, it takes 1 unit of time to transfer data between adjacent servers. Given a set of servers, calculate the minimum time required to synchronize data among them.
Assume all servers form a circle, where each server takes 1 unit of time to transmit to its next adjacent server. You need to calculate the minimum time for the specified set of servers to synchronize data.
Example:
If servers form a circle as 1->2->3->4->5->6->7->8->1, and the server set is [2, 6, 8].
Output: 4
Possible paths include:
From 2 to 6 to 8 takes 6 units of time
From 2 to 8 to 6 takes 4 units of time
Example
Input
8
2
6
8