Instagram
youtube
Facebook
Twitter

Python Maximum Capacity Program Codechef Solution

           Python Maximum Capacity Programme Codechef Solution

Problem

A building lift has a maximum capacity of 500 kilogrammes.
However, due to the pandemic, at most 8 people can use the lift at once.


There are X friends, each having a weight of Y kilogrammes. Find out whether all of them can use the lift at once.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case contains two space-separated integers X and Y: the number of friends and the weight of each friend.

Output Format

For each test case, output on a new line yes if all friends can use the lift at once. Otherwise, output NO.

You may print each character in uppercase or lowercase. For example, NO, NO, NO, and nO are all considered the same.

Constraints:

  • 1≤T≤1000
  • 1<=X,Y<=100

Sample Input:

7 75 

8 50 

10 10 

5 100

Sample Output:

NO 

YES 

NO 

YES

 

Solution:

for i in range(int(input(“Enter the number of terms: “))):

    H,G=map(int,input(“Enter the number of friends and their weights: “).split())

    s=H*G 

    if(H<9 and s<=500):

        print("YES")

    else:

        print("NO")


 

 

Steps to solve this problem:

  1. Ask the user to enter the number of terms.
  2. In loop, Ask the user to enter the number of friends and their weights, and using the map() function, get iterator objects and store them in H and G.
  3. Calculate H*G and store the result in s.
  4. Check if H is less than 9 and s is less than or equal to 500, then print "yes," otherwise print "no."