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

19117번 - Master Zhu and Video 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB182266.667%

문제

Master Zhu is watching a video. He wants to adjust the sound volume from $p$ dB to $q$ dB. Master Zhu is powerful enough to control the sound volume mentally. He needs one second to issue one order. So, each second, he may either issue an order "Up!", issue an order "Down!", or do nothing.

If he issues an order "Up!", the volume increases by 1ドル$ dB. An order "Down!" works in a more compilcated way: if on the previous second, there was an order "Down!" and the volume decreased by $x$ dB, it decreases by 2ドル \cdot x$ dB, otherwise the volume decreases by 1ドル$ dB.

If after some order the volume becomes negative, the system will break, so Master Zhu must be careful.

Find the minimum time needed for Master Zhu to adjust the volume from $p$ dB to $q$ dB.

입력

The first line of input contains one integer $T,ドル the number of test cases (1ドル \le T \le 3 \cdot 10^5$).

Each of the next $T$ lines contains two integers $p$ and $q$ (0ドル \le p, q \le 10^9$).

출력

For each test case, print a single line with a single integer: the minimum time in seconds Master Zhu needs to adjust the volume.

제한

예제 입력 1

2
1 5
7 3

예제 출력 1

4
4

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 8: UESTC Selection F번

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

출처

대학교 대회

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

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