Driving Test Track
Time limit2sMemory limit1024 MB
Given n front-radar cars and m corner-radar cars, find the minimum carrier capacity k and the fewest road crossings to move all cars west without mixed types on one side.
- Level
Medium7 of 10
- Topics
- Math, Greedy, Simulation
- Solved
- No attempts yet
Problem
Hyundai Mobis has run a software academy at its Technical Research Institute in Yongin, Gyeonggi-do, since 2018, where more than 400 researchers can take software job training at the same time. The institute currently has about 800 software designers in Korea, and it plans to grow that number to about 4,000 by 2025, more than five times the current size.
Alongside building software staff at domestic research institutes, the company is expanding its India research institute into a global base for software specialization.
In 2018, it also became the first domestic auto parts maker to form a big data team, and it actively applies big data and artificial intelligence to research and development.
A new driving test track built by Hyundai Mobis is validating two kinds of artificial intelligence software by installing them on real cars. Each software program is linked to a front radar or a corner radar. The test track has cars in total. Of these, cars have a front radar, and the other cars have a corner radar.
The test track is divided into an east section and a west section. At the start, all cars are driving only in the east section, and you are monitoring the cars from the east section. You can monitor only the section where you are. You cannot monitor the other section.
The two radar types cannot yet communicate with each other. If cars with different radar types are in the section you are not monitoring at the same time, the cars will stop their driving tests. Your goal is to move all cars to the west section without any car stopping its test.
Specifically, a road connects the east and west sections. You can take at least 0 and at most cars at once and move from one section to the other.
For example, suppose the east section starts with 3 front radar cars and 2 corner radar cars, and . You can cross the road to the west section with 2 corner radar cars. After you move, you can monitor the west section. Likewise, you can take 2 or fewer cars back from the west section to the east section, and then monitor the east section.
Find the minimum value of that moves all cars to the west section without stopping any driving test, and the minimum number of times you must cross the road at that . Output both values.
Input
The first line contains the number of test cases .
Each of the following lines contains two integers and , separated by a space, for one test case.
Output
For each test case, print on one line the minimum value of and the minimum number of road crossings at that , separated by a space. It can be proven that both values are less than within the input range.