# Going to office | hackerearth practice problem solution

## problem:-

Alice has the following two types of taxis:

• Online taxi: It can be booked by using an online application from phones
• Classic taxi: It can be booked anywhere on the road

The online taxis cost

${O}_{c}$

for the first

${O}_{f}$

km and

${O}_{d}$

for every km afterward. The classic taxis travel at a speed of

${C}_{s}$

km per minute. The cost of classic taxis are

${C}_{b}$

${C}_{m}$

, and

${C}_{d}$

that represents the base fare, cost for every minute that is spent in the taxi, and cost for each kilometer that you ride.
You are going to the office from your home. Your task is to minimize the cost that you are required to pay. The distance from your home to the office is D. You are required to select whether you want to use online or classic taxis to go to your office. If both the taxis cost the same, then you must use an online taxi.
Input format

• First line: Single integer
$D$

that denotes the distance from your house to the office

• Next line: Three integers
${O}_{c}$

,

${O}_{f}$

, and

${O}_{d}$

• Next line: Four integers
${C}_{s}$

${C}_{b}$

${C}_{m}$

, and

${C}_{d}$

Output format
If you select an online taxi to travel, then print a string ‘Online Taxi‘. Otherwise, select ‘Classic Taxi‘. You can print this string in a new, single line.
Constraints
1

$\le$

$\le$

109

SAMPLE INPUT

`136 7 44 2 1 2`
SAMPLE OUTPUT

`Online Taxi`
Explanation

If Felix choose to use Online Taxi, it will cost Felix a total of

$6+\left(13-7\right)×4=30$

While the classic taxi will cost Felix a total of

$2+⌊\frac{13}{4}⌋×1+13×2=31$

Therefore Felix will choose Online Taxi over Classic Taxi

Time Limit:1.0 sec(s) for each input file.
Memory Limit:64 MB
Source Limit:1024 KB

## solution:-

#include<stdio.h>
int main()
{
long long int d,oc,of,od,cs,cb,cm,cd;
long long int cost1,cost2;
scanf(“%lld”,&d);
scanf(“%lld %lld %lld”,&oc,&of,&od);
scanf(“%lld %lld %lld %lld”,&cs,&cb,&cm,&cd);
cost1=oc+((dof)*od);
cost2=cb+((d/cs)*cm)+(d*cd);
if(cost1<cost2||cost1==cost2)
printf(“Online Taxi”);
else
printf(“Classic Taxi”);
return 0;
}

Recommended post:-