A hostel has rooms in a straight line. It has to accommodate people. Unfortunately, out of these people, of them are infected with chickenpox. Due to safety norms, the following precaution must be taken:
- No person should occupy a room directly adjacent to a room occupied by a chickenpox-infected person. In particular, two chickenpox-infected people cannot occupy adjacent rooms.
For example, if room has a chickenpox-infected person, then nobody should occupy rooms and . Similarly, if room has a chickenpox-infected person then nobody should occupy room .
What's the minimum value of for which all the people can be accommodated in the hostel, following the above condition?
Input Format
- The first line of input contains a single integer — the number of test cases. The description of test cases follows.
- The first and only line of each test case contains two integers and — the total number of people and the number of chickenpox-infected people.
Output Format
For each test case, output on a new line a single integer — the minimum value of for which all the people can be accommodated in the hostel.
Constraints
Sample Input 1
3
4 0
5 3
3 3
Sample Output 1
4
8
5
Explanation
Note: Below, represents a room occupied by a chickenpox-infected person, represents a room occupied by an uninfected person, and represents an empty room.
Test case : One of the possible ways to accommodate the people in rooms is:
Test case : One of the possible ways to accommodate the people in rooms is:
Test case : One of the possible ways to accommodate the people in rooms is:
solution link 1
https://shareus.in/?i=yScFNErxQ
if 1st link is not work then click on another link
Solution link 2
Solution link 3
Solution link 4
How to get link tutorial video link
No comments:
Post a Comment