Most Cost Efficient Car Problem Statement
Given the cost and operational details for both 'Petrol' and 'Diesel' cars, determine which type is more cost-efficient for a period of exactly 6 months. Output an integer indicating the result: '0' for Petrol car, '1' for Diesel car, and '-1' if both are equally efficient.
Explanation:
You will be provided with details such as price, monthly maintenance cost, kilometers per liter, fuel price per liter, and kilometers driven per month for both Petrol and Diesel cars. Calculate the total cost for a 6-month period for both cars to decide the most cost-efficient option.
Input:
The first line contains an integer ‘T’ representing the number of test cases.
For each test case, the next two lines contain space-separated integers:
1. For the Petrol car: Price, maintenance cost per month, km per liter, fuel price per liter, km per month.
2. For the Diesel car: Price, maintenance cost per month, km per liter, fuel price per liter, km per month.
Output:
For each test case, output '0' if Petrol is more efficient, '1' if Diesel is more efficient, or '-1' if both are equally efficient.
Example:
Input:
1
780000 500 35 75 145
850000 1000 30 80 200
Output:
0
Constraints:
1 <= T <= 10^5
1 <= priceOfCar, maintenanceCostPerMonth, numberOfkilometerCarRunInOneLiter, pricePerLiter, numberOfKilometerCarRunInaMonth <= 10^9
- Time Limit: 1 second
Note:
Implementation should focus on efficiency due to potentially high constraints.

Determine the most cost-efficient car (Petrol or Diesel) for a 6-month period based on given details.
Calculate total cost for 6 months for both Petrol and Diesel cars
Compare the total costs to determi...read more


Reviews
Interviews
Salaries
Users

