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

20906번 - Flip Flow 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 512 MB13812311794.355%

문제

For over 600 years, the hourglass has been a well-known timekeeping instrument. An hourglass consists of two glass flasks arranged one above the other which are connected by a narrow channel. Inside the hourglass there is sand which slowly flows from the upper to the lower flask. Hourglasses are typically symmetrical so that the sand always takes the same amount of time to run through, regardless of orientation. For the purposes of this problem, we also assume that the flow rate of the sand is a known constant and does not depend on the amount or distribution of sand in the upper half.

Your friend Helen was bored and has been playing around with her hourglass. At time 0ドル,ドル all the sand was in the lower half. Helen flipped the hourglass over several times and recorded all the moments at which she did so. How many seconds does she need to wait from the current time until all the sand is back in the lower half?

입력

The input consists of:

  • One line with three integers $t,ドル $s$ and $n,ドル where
  • $t$ (1ドル \le t \le 10^6$) is the current time;
  • $s$ (1ドル \le s \le 10^6$) is the amount of sand in the hourglass, in grams;
  • $n$ (1ドル \le n \le 1,000円$) is the number of times the hourglass was flipped.
  • One line with $n$ integers $a_1,\dots,a_n$ (0ドル < a_1 < \dots < a_n < t$), the times at which the hourglass was flipped.

All times are given in seconds. You may assume that the sand flows from the top to the bottom at a constant rate of 1ドル$ gram per second.

출력

Output the time in seconds needed for the hourglass to run out starting from time $t$.

제한

예제 입력 1

10 7 2
4 9

예제 출력 1

4

예제 입력 2

2000 333 3
1000 1250 1500

예제 출력 2

0

예제 입력 3

100 10 5
15 20 93 96 97

예제 출력 3

5

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2020 F번

  • 문제를 만든 사람: Paul Wild
(追記) (追記ここまで)

출처

대학교 대회

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

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