# TV Discount Codechef Solution

#### ByBrokenprogrammers

Dec 23, 2022

Hello Programmers In this post, you will know how to solve the TV Discount Codechef Solution. The Problem Code is TVDISC.

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.

## Problem

Chef is looking to buy a TV and has shortlisted two models. The first one costs AA rupees, while the second one costs BB rupees.

Since there is a huge sale coming up on Chefzon, Chef can get a flat discount of C rupees on the first TV, and a flat discount of D rupees on the second one.

Help Chef determine which of the two TVs would be cheaper to buy during the sale.

### Input Format

• The first line contains a single integer T — the number of test cases. Then the test cases follow.
• The first and only line of each test case contains four space-separated integers A, B, C, and D — the marked price (in rupees) of the first TV, the marked price (in rupees) of the second TV, the flat discount (in rupees) of the first TV, and the flat discount (in rupees) of the second TV.

### Output Format

For each test case, print a single line containing the string `First` if the first TV is cheaper to buy with discount, or `Second` if the second TV is cheaper to buy with discount. If both of them cost the same after discount, print `Any`.

You may print each character of the string in uppercase or lowercase (for example, the strings `first``First``fIRSt`, and `FIRST` will all be treated as identical).

• 1≤T≤5000
1≤A,B≤100
0≤C≤A
0≤DB

### Sample 1:

Input

```3
85 75 35 20
100 99 0 0
30 40 0 10```

Output

`FirstSecondAny`

### Explanation:

Test case 11: The cost of the first TV after discount is 85 – 35 = 50, while the cost of the second TV after discount is 75 – 20 = 55. Thus the first TV is cheaper to buy than the second.

Test case 22: The cost of the first TV after discount is 100 – 0 = 100, while the cost of the second TV after discount is 99 – 0 = 99 Thus the second TV is cheaper to buy than the first.

Test case 33: The cost of the first TV after discount is 30 – 0 = 30, while the cost of the second TV after discount is 40 – 10 = 30. Since they are equal, Chef can buy any of them.

### TV Discount Codechef Solution in JAVA

```/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
int x=a-c;
int y=b-d;
if(x>y)
System.out.println("Second");
else if(y>x)
System.out.println("First");
else
System.out.println("Any");
}
}
}```

### TV Discount Codechef Solution in CPP

```#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d",x)
#define pl(x)	printf("%lld",x)
#define ps(s)	printf("%s",s)
#define pnl()   printf("\n")
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 18 * 103, M = N;
#define top(a,b) (ll)((a+b-1)/b)
//=======================
vi g[N];
void matrix(ll n, ll m){
char s[101][101];
while(cin>>n>>m){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>s[i][j];
}
}
}
}
int fact(ll n);
// Returns factorial of n
int fact(ll n)
{
ll res = 1;
for (int i = 2; i <= n; i++)
res = res * i;
return res;
}
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
int main() {
ll t;
cin >> t;
while(t--){
ll a , b, c, d;
cin >> a >> b >> c >> d;
a = a - c;
b = b - d;
if(a > b)
cout << "SECOND" << endl;
else if(a < b)
cout << "FIRST" << endl;
else if(a == b)
cout << "ANY" << endl;
}
return 0;
}
int mpow(int base, int exp) {
base %= mod;
int result = 1;
while (exp > 0) {
if (exp & 1) result = ((ll)result * base) % mod;
base = ((ll)base * base) % mod;
exp >>= 1;
}
return result;
}
void ipgraph(int n, int m){
int i, u, v;
while(m--){
cin>>u>>v;
g[u-1].pb(v-1);
g[v-1].pb(u-1);
}
}
void dfs(int u, int par){
for(int v:g[u]){
if (v == par) continue;
dfs(v, u);
}
}```

### TV Discount Codechef Solution in Python

```# cook your dish here
t = int(input())
for i in range(t):
x,y,z,a = map(int,input().split())
b = x - y
c = z - a
if (b == c):
print("Any")
elif (b > c):
print("Second")
else:
print("First")```

Disclaimer: The above Problem (TV Discount Codechef Solution) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.