The Cooler Dilemma 1 WATERCOOLER1 Solution

The Cooler Dilemma 1 WATERCOOLER1 Solution

The summer is at its peak in Chefland. Chef is planning to purchase a water cooler to keep his room cool. He has two options available:

Rent a cooler at the cost of X coins per month.
Purchase a cooler for Y coins.
Given that the summer season will last for M months in Chefland, help Chef in finding whether he should rent the cooler or not.

Chef rents the cooler only if the cost of renting the cooler is strictly less than the cost of purchasing it. Otherwise, he purchases the cooler.

Print YES if Chef should rent the cooler, otherwise print NO.

Input Format

  • The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains three integers X, Y and M, as described in the problem statement.

Output Format

  • For each test case, output YES if Chef should rent the cooler, otherwise output NO.
  • You may print each character of the string in uppercase or lowercase (for example, the strings YeS, yEs, yes and YES will all be treated as identical).

Constraints

  • 1≤T≤100
  • 1≤X,M≤104
  • 1≤Y≤108

Sample Input 1
3
5 10 1
5 10 2
5 10 3

Sample Output 1
YES
NO
NO

Explanation

  • Test case 1: Cost of renting the cooler =5 coins. Cost of purchasing the cooler =10 coins. So, Chef should rent the cooler as the cost of renting the cooler for 1 month is strictly less than purchasing it.
  • Test case 2: Cost of renting the cooler =10 coins. Cost of purchasing the cooler =10 coins. So, Chef should not rent the cooler as the cost of renting the cooler for 2 months is not strictly less than purchasing it.
  • Test case 3: Cost of renting the cooler =15 coins. Cost of purchasing the cooler =10 coins. So, Chef should not rent the cooler as the cost of renting the cooler for 3 months is not strictly less than purchasing it.

SOLUTION

Program: The Cooler Dilemma 1 WATERCOOLER1 Solution in Python

for _ in range (int(input())):
    x,y,z = map(int, input().split())
    r  = x * z
    
    if (y > r ):
        print("Yes")
    else:
        print("No")
  

Program: The Cooler Dilemma 1 WATERCOOLER1 Solution in C++

#include <iostream>
using namespace std;

int main() {
    long long t;
    cin>>t;
    while(t--)
    {
        long long x,y,m;
        cin>>x>>y>>m;
        {
            if((x*m)<y)
            {
                cout<<"YES"<<"\n";
            }
            else
            {
                cout<<"NO"<<"\n";
            }
        }
    }
	return 0;
}

Program: The Cooler Dilemma 1 WATERCOOLER1 Solution in Java

import java.util.*;
import java.lang.*;
import java.io.*;

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 x , y , m;
		 x = sc.nextInt();
		 y = sc.nextInt();
		 m = sc.nextInt();
		 
		 int tp = x * m;
		 if(tp < y)
			 System.out.println("YES");
		 else
			 System.out.println("NO");
		 
		 
		 
	  }
	}
}

Related:

Leave a Comment

one × two =