HackerEarth Going to office problem solution YASH PAL, 31 July 2024 In this HackerEarth Going to office problem solution Alice has the following two types of taxis: Online taxi: It can be booked by using an online application on phones Classic taxi: It can be booked anywhere on the road The online taxis cost Oc for the first Of km and Od for every km afterward. The classic taxis travel at a speed of Cs km per minute. The cost of classic taxis is Cb, Cm, and Cd that represent 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. HackerEarth Going to office problem solution. #include<iostream>using namespace std;typedef long long ll;int main(){ ll d; cin >> d; ll oc, of, od; cin >> oc >> of >> od; ll cs, cb, cm, cd; cin >> cs >> cb >> cm >> cd; ll online = (d <= of)?oc:oc + (od * (d - of)); ll timeClassic = d / cs; ll classic = cb + timeClassic * cm + cd * d; if(online <= classic) cout << "Online Taxi" << endl; else cout << "Classic Taxi" << endl;} Second solution #include <bits/stdc++.h>#define int long longtypedef long long ll;using namespace std;const int maxn = 2e5 + 17;int32_t main(){ ios::sync_with_stdio(0), cin.tie(0); int d; cin >> d; int oc, of, od; cin >> oc >> of >> od; int cs, cb, cm, cd; cin >> cs >> cb >> cm >> cd; ll fc = 0; if(d <= of) fc = oc; else fc = oc + (d - of) * od; ll sc = 0; sc = (ll) (d + cs - 1) / cs * cm + cb + cd * d; cerr << fc << ' ' << sc << 'n'; if(fc <= sc) cout << "Online Taxin"; else cout << "Classic Taxin";} coding problems