[Solution] Control the Pollution solution codechef

Control the Pollution solution codechef – There are two types of vehicles in Chefland.

  • Bus which has a capacity of 100100 people.
  • Car which has a capacity of 44 people.

There are NN people who want to travel from place AA to place BB. You know that a single bus emits XX units of smoke while a single car emits YY units of smoke in their journey from AA to BB.

You want to arrange some buses and cars to carry all these NN people such that total smoke emitted is minimized. Output the minimized smoke value.

Control the Pollution solution codechef

  • First line will contain TT, the number of test cases. Then the test cases follow.
  • Each test case contains three integers NNXXYY – the number of people who want to travel, the units of smoke emitted by a bus and the units of smoke emitted by a car respectively.

Output Format

For each test case, output the minimum units of smoke emitted in transporting the NN people.

Constraints

  • 1T10001≤T≤1000
  • 1N10001≤N≤1000
  • 1X,Y10001≤X,Y≤1000

Control the Pollution solution codechef

 

3
9 40 8
15 20 20
105 80 10

Sample Output 1 

24
20
100

Control the Pollution solution codechef

Test case-1: In the optimal case, we will use 33 cars where the 11-st and 22-nd car will carry 44 people each and the 33-rd car will carry 11 person.

Therefore smoke emitted =3×8=24=3×8=24 units.

Test case-2: In the optimal case, we will use 11 bus to carry all the 1515 people.

Therefore smoke emitted =1×20=20=1×20=20 units.

Test case-3: In the optimal case, we will use 11 bus to carry 100100 people and use 22 cars to carry the remaining 55 people.

Therefore smoke emitted =1×80+2×10=100=1×80+2×10=100 units.

Leave a Comment