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

23784번 - Eidam-Sand Lair 다국어

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

문제

In your base you have dug through sand and rock to construct a deep pit with stairs and a lift. The pit goes very deep into the ground where on various floors you leave equipment and on the deepest levels you leave cheeses to age, particularly Eidam. You often take a stroll downstairs, but wonder whether it is faster to go up to the surface by foot or take a lift for a part or all of the trip.

You know the position and the speed of yourself and the lift. The surface floor is numbered 0, positive numbers denote underground floors by their distance to the surface. You are alone on the Mars so only you will use the lift. Also, it takes (you and lift) almost no time to start and stop moving so you will neglect these. When the lift is called to multiple floors, it moves to them in the same order in which it was called. The lift is not very special – once you enter it, you may order it to go to an arbitrary floor. In such case, any previous calls must be processed first.

입력

The first input line contains a single integer T (1 ≤ T ≤ 104), the number of test cases. Next T lines contain one test case each. Each test case is composed of four integers: Yp, Lp, Ys, Ls where 0 ≤ Yp, Lp ≤ 109 are the initial floors of you and the lift, and 0 < Ys, Ls ≤ 106 are the times it takes you and of the lift to move by one floor, respectively.

출력

For each test case, print a single integer – the minimum time it takes you to move from your initial floor to the 0-th floor.

제한

예제 입력 1

2
2 20 10 2
10 20 10 2

예제 출력 1

20
40

힌트

Sample Input 1 contains two test cases. In the first one, you will rather walk to 0-th floor than to wait for the lift which is 18 floors away. In the second test case, an example of the fastest way is when you call the lift and walk 1 floor upstairs in the meantime, then you call the lift to 9-th underground floor and wait for the lift which you then take to the 0-th floor.

출처

ICPC > Regionals > Europe > Central European Regional Contest > CTU Open Contest > CTU Open Contest 2021 I번

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

출처

대학교 대회

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

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