# CHEFTRANS - Editorial

Setter:
Tester: Nishank Suresh
Editorialist: Taranpreet Singh

Cakewalk

None

# PROBLEM

Vacations have arrived and Chef wants to go to his home in ChefLand. There are two types of routes he can take:

• Take a flight from his college to ChefArina which takes X minutes and then take a bus from ChefArina to ChefLand which takes Y minutes.
• Take a direct train from his college to ChefLand which takes Z minutes.

Which of these two options is faster?

# QUICK EXPLANATION

The total time taken by the first option is X+Y and the total time taken by the second option is Z. Print TRAIN, PLANEBUS or EQUAL depending on whether X+Y \gt Z, X+Y \lt Z or X+Y = Z

# EXPLANATION

This problem is all about implementing the problem statement. We can see that the time taken in the first option is X minutes on flight and Y minutes in bus, leading to a total of X+Y minutes, and the second option takes a total of Z minutes.

We need to choose the option which results in lower time and print it.

A sample code would be something like this

``````int X, Y, Z;
cin>>X>>Y>>Z;
if (X+Y < Z) print ("PLANEBUS")
else if (X+Y > Z) print("TRIAN")
else print("EQUAL")
``````

# TIME COMPLEXITY

The time complexity is O(1) per test case.

# SOLUTIONS

Setter's Solution
Tester's Solution
``````for _ in range(int(input())):
x, y, z = map(int, input().split())
if x + y < z:
print('planebus')
elif x + y > z:
print('train')
else:
print('Equal')
``````
Editorialist's Solution
``````import java.util.*;
import java.io.*;
class CHEFTRANS{
//SOLUTION BEGIN
void pre() throws Exception{}
void solve(int TC) throws Exception{
int X = ni(), Y = ni(), Z = ni();
if(X+Y < Z)pn("PLANEBUS");
else if(X+Y > Z)pn("TRAIN");
else pn("EQUAL");
}
//SOLUTION END
void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
static boolean multipleTC = true;
void run() throws Exception{
out = new PrintWriter(System.out);
//Solution Credits: Taranpreet Singh
int T = (multipleTC)?ni():1;
pre();for(int t = 1; t<= T; t++)solve(t);
out.flush();
out.close();
}
public static void main(String[] args) throws Exception{
new CHEFTRANS().run();
}
int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
void p(Object o){out.print(o);}
void pn(Object o){out.println(o);}
void pni(Object o){out.println(o);out.flush();}
String n()throws Exception{return in.next();}
String nln()throws Exception{return in.nextLine();}
int ni()throws Exception{return Integer.parseInt(in.next());}
long nl()throws Exception{return Long.parseLong(in.next());}
double nd()throws Exception{return Double.parseDouble(in.next());}

StringTokenizer st;
}

}

String next() throws Exception{
while (st == null || !st.hasMoreElements()){
try{
}catch (IOException  e){
throw new Exception(e.toString());
}
}
return st.nextToken();
}

String nextLine() throws Exception{
String str = "";
try{