Logo
(追記) (追記ここまで)

7655번 - Leap Frog 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB39151242.857%

문제

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.

입력

The input file will contain multiple test cases. Each test case will begin with a single line containing a single integer n (where 2 ≤ n ≤ 100000). The next line will contain a list of integers x1 x2 . . . xn where 0 ≤ x1 < x2 . . . < xn ≤ 1000000. The end-of-file is denoted by a single line containing “0”.

출력

For each input test case, 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.

제한

예제 입력 1

6
3 5 9 12 15 17
6
3 5 9 12 30 40
0

예제 출력 1

3
-1

힌트

출처

University > Stanford Local ACM Programming Contest > SLPC 2009 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /