Annual Sport meeting in S University starts again. This year, the rule of relay running is modified by president of sports department. The rule after modification is as follows:
The total length of the relay running is L (1<=L<= 109). There are n (0<= n <= 500000) possible places to place a new racer (there is a race in the start line). Every racer runs to the next racer in front of him and the final racer runs to the finish line. But the number of racers is limited to a number m (1<=m<=n+1). Team of class 1788 does not want any of them to run too much. Therefore, they wish to minimize the longest distance that any one of them needs to run.
The input contains several test cases. The
first line of each case contains three positive integer L, n, and
m.
Then n lines follow. Each stands for the distance from the start line to the
nth possible place to place new racer, two places will not be the same.
For each case, output an integer which is the minimium longest distance that any one of class 1788 needs to run.
Arrays.sort() is allowed in this problem.
Since we don't know how many testcases are there, we need to determine whether the input is finished. Here are the sample code:
JAVA:
public static void main(String[] args) {
Scanner scanner =newScanner(System.in);
while(scanner.hasNext()) {
//to do
}
}
C:
#include<stdio.h>
int main(){
int n;
while(scanf("%d",&n)!=EOF){
// do something
}
return 0;
}
C++:
#include<iostream>
int main(){
int n;
while(std::cin>>n){
// do something
}
return 0;
}