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

25281번 - Bike Party 서브태스크스페셜 저지다국어

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

문제

There will be multiple great parties tonight after the competition, and Robin is very excited for a night out. At each party Robin will be served one drink containing a fixed amount of alcohol measured in alcohol units, that is consumed immediately upon arrival. The hosts of the parties are not all equally generous. They put different amounts of alcohol in their drinks and some might even serve a non-alcoholic drink!

The parties are located along a circular route. Robin will bike along the circle, visiting every party once, going to bed at the last party which is the same as the first party. Each meter of biking sobers up one unit of alcohol (i.e., the alcohol level is reduced by one). Robin starts completely sober (i.e., at alcohol level zero).

Find a party to start (and end) the journey at such that Robin never becomes sober at any point in time during the night. It is not even allowed to become sober in the moment of arrival to a new location (even if Robin immediately drinks more alcohol upon arrival, the brief moment of soberness would ruin the experience). The only exception is that it is allowed to become sober in the moment when Robin reaches the final party and goes to bed.

Robins alcohol level has no upper limit.

입력

The first line of input contains a single integer $ 3 \leq N \leq 100,000円 ,ドル the number of parties.

Then follow $N$ lines. Each line, numbered $i \in \{ 1, 2, \ldots, N \},ドル consists of two integers $ 0 \leq A_i \leq 10^9 $ and $ 0 < D_i \leq 10^9 ,ドル where $A_i$ is the amount of alcohol Robin will receive at the $i$th party in alcohol units, and $D_i$ is the distance to the next party along the circle (to party $i+1$ if $i < N,ドル and to party 1ドル$ if $i == N$) in meters.

출력

A single integer, the 1ドル$-based index of the party where Robin should start the bike party without running out of alcohol.

If no solution exists output a single line with the string "impossible".

If there are multiple possible answers, any will be considered correct.

제한

서브태스크

번호배점제한
120

$ N \leq 1,000円 $.

240

$ \sum_i A_i = \sum_i D_i $.

340

No further restrictions.

예제 입력 1

3
10 5
10 5
10 20

예제 출력 1

1

예제 입력 2

3
2 2
2 2
2 2

예제 출력 2

impossible

힌트

출처

Contest > Swedish Coding Cup > LTH Challenge 2022 E번

  • 문제를 만든 사람: Björn Magnusson, Jonatan Nilsson, Måns Magnusson

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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