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

30494번 - Funicular Frenzy 다국어

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

문제

You are on a skiing trip in the Alps and need to take a funicular.1 However, there usually is a long queue for the funicular to bring you to the top of the mountain. Being someone who hates wasting time in the morning, you want to find the best moment to start queueing in order to minimize queueing time.

The funicular station is open for \(n\) minutes per day. A carriage transports \(c\) people at once, and one carriage leaves exactly every minute. For every minute the funicular is open today, you know the number of people arriving.

You want to arrive when the station is open, exactly at the start of a minute, like everyone else. Note that you are a sociable person and if there are other people arriving at the same minute as you, you let them go first, after which you stand in the queue.

Calculate at which minute you should arrive to have minimal waiting time, or determine that it is impossible to catch a ride today. If there are two times achieving the same minimal waiting time, give the earliest occasion.


1 A funicular is a type of cable railway system laid on a steep slope, where two counterbalanced carriages are attached to opposite ends of a haulage cable, which is looped over a pulley at the upper end of the track.

입력

The input consists of:

  • One line with two integers \(n\) and \(c\) (\(1 \leq n \leq 10^5\), \(1 \leq c \leq 10^9\)), the number of minutes the funicular is open today and the number of people one funicular carriage takes up the mountain each minute.
  • One line with \(n\) integers \(a_0, \dots, a_{n-1}\) (\(0 \leq a_i \leq 10^9\)), the number of new people showing up \(i\) minutes after the funicular opens.

출력

If it is not possible to take the funicular today, output "impossible". Else, output the least number of minutes after opening time you should enter the queue, such that the waiting time is minimized.

제한

예제 입력 1

5 1
5 0 0 0 0

예제 출력 1

impossible

예제 입력 2

5 4
8 6 4 2 0

예제 출력 2

0

예제 입력 3

10 10
12 11 10 9 8 7 6 5 4 3

예제 출력 3

5

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2023 F번

  • 문제를 만든 사람: Ragnar Groot Koerkamp
(追記) (追記ここまで)

출처

대학교 대회

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

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