Jumping Jack
시간 제한2초메모리 제한512 MB
정렬된 체크포인트 위치가 주어질 때, 잭이 정확히 k번 점프해 처음에서 마지막 체크포인트까지 도달하는 최대 점프 레벨을 구하고, 불가능하면 -1을 출력한다.
문제
For as long as he could remember, Jack has loved to jump. His goal is to become an Olympic athlete someday, so he spends lots of time practicing his jumping skills. Jack has set up a course of checkpoints along a straight line from his starting point. To go through this course, Jack picks a jumping level, which defines how far he can travel along these checkpoints. Specifically, if Jack is at a checkpoint located at position and has picked jumping level , he will jump to the furthest checkpoint that is at or before position . If there is no checkpoint in the range , then Jack will fail to finish the course because he cannot make a jump.
Jack wants to know how he should pick his jumping level so that he can make it through the course. Additionally, in order to get in enough practice without overexercising, Jack wants to finish the course in exactly jumps. Given the positions of all the checkpoints, find the maximum jump level that Jack should pick to make it through the course with exactly jumps or determine if it is impossible to do so.
입력
The first line of input is integers separated by spaces and such that and . The next line is distinct integers in sorted order that represent the checkpoint positions, , that Jack jumps to. You are guaranteed that and
출력
Output a single integer representing the maximum possible jump size such that Jack takes exactly jumps through the checkpoints given that jump size. If no such jump size exists, output .