PROBLEM LINK:
Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4
Setter: Utkarsh Gupta
Tester: Abhinav Sharma
Editorialist: Kanhaiya Mohan
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
Chef wants to reach home as soon as possible. He has two options:
- Travel with his bike which takes X minutes.
- Travel with his car which takes Y minutes.
Which of the two options is faster or they both take the same time?
EXPLANATION:
We are given that travel by bike takes X minutes and travel by car takes Y minutes. Following cases are possible:
-
X<Y: This means that travel by bike is faster. Thus, we print
BIKE
. -
X>Y: This means that travel by car is faster. Thus, we print
CAR
. -
X=Y: Both vehicles take the same amount of time. Thus, we print
SAME
.
Examples
-
X = 9, Y = 7: Here X>Y. Thus, car is faster and we print
CAR
. -
X = 3, Y = 5: Here X<Y. Thus, bike is faster and we print
BIKE
. -
X = 4, Y = 4: Here X=Y. Thus, both take same time and we print
SAME
.
TIME COMPLEXITY:
We just need to compare the values X and Y. Thus, the time complexity is O(1) per test case.
SOLUTION:
Editorialist's Solution
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int x, y;
cin>>x>>y;
if(x<y){
cout<<"BIKE";
}
else if(x>y){
cout<<"CAR";
}
else{
cout<<"SAME";
}
cout<<endl;
}
return 0;
}