프로그램 명: stfd_leapfrog
제한시간: 1 초

Jack and Jill play a game called "Leap Frog" in which they alternate turns jumping over each other. Both Jack and Jill can jump a maximum horizontal distance of 10 units in any single jump. You are given a list of valid positions x1 , x2 , ...,xn where Jack or Jill may stand. Jill initially starts at position x1 , Jack initially starts at position x2 , and their goal is to reach position xn.

Determine the minimum number of jumps needed until either Jack or Jill reaches the goal. The two players are never allowed to stand at the same position at the same time, and for each jump, the player in the rear must hop over the player in the front.

입력

출력

Print the minimum total number of jumps needed for both players such that either Jack or Jill reaches the destination, or -1 if neither can reach the destination.

입출력 예

입력

6
3 5 9 12 15 17

출력

3

입력

6
3 5 9 12 30 40

출력

-1
출처:standford/2009/

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]