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

31363번 - Lunch 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB172213.333%

문제

The swamp looks like a narrow lane with length $n$ covered by floating leaves sized 1ドル,ドル numbered from 1ドル$ to $n$ with a fly sitting on the top of each. A little toad is sitting on one of the leaves instead of a fly. Its name is Kvait and it is about to have lunch. It can jump to the bordering leaf or jump it over to the next one in any direction. When landing it eats a fly. Kvait is already quite a big toad and the leaves are unstable so when it jumps away the leaf starts sinking.

In order to have lunch Kvait needs to eat all of the flies. It starts his journey from the leaf with number $s$ and has to finish on the leaf with number $f$. Yet jumping to the bordering leaf takes more Kvait’s energy than skipping a leaf over. It is necessary to plan the toad’s movements to get lunch with minimal energy spent.

입력

Single line contains three integers $n,ドル $s,ドル $f$ (2ドル \le n \le 10,000円,ドル 1ドル \le s, f \le n$) --- the number of leaves, number of a starting leaf and the number of the finish leaf respectively.

출력

Output the minimal number of jumps to the bordering leaves required for the toad to have lunch. If there is no way to eat up, output a single number $-1$.

제한

예제 입력 1

4 1 2

예제 출력 1

1

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 11: Grand Prix of Tatarstan > Division 1 H번

Contest > Open Cup > 2014/2015 Season > Stage 11: Grand Prix of Tatarstan > Division 2 H번

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

출처

대학교 대회

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

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