A – Save Water Save Life CodeChef Solution

Problem – A – Save Water Save Life CodeChef Solution

To address the situation of Water Scarcity in Chefland, Chef has started an awareness campaign to motivate people to use greywater for toilets, washing cars, gardening, and many other chores which don’t require the use of freshwater. These activities presently consume y liters of water every week per household and Chef thinks through this campaign he can help cut down the total usage to ⌊2y​⌋.

Assuming x liters of water every week per household is consumed at chores where using freshwater is mandatory and a total of C liters of water is available for the entire Chefland having H households for a week, find whether all the households can now have sufficient water to meet their requirements.

###Input:

  • First line will contain T, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, four integers H,x,y,C.

###Output: Print a single line containing the string "YES" if it is possible to meet the requirement of all the households in Chefland or "NO" if it is impossible (without quotes).

You may print each character of each string in uppercase or lowercase (for example, the strings “yEs”, “yes”, “Yes” and “YES” will all be treated as identical).

###Constraints

  • 1≤T≤300
  • 1≤H,x,y≤10
  • 1≤C≤100

Sample 1:

Input:
3
3 1 1 3
1 1 1 2
2 1 1 1
Output:
YES
YES
NO

Explanation:

TestCase 1: Total consumption of a single household after using greywater = 1 +1+ ⌊21​⌋ = 1+0 = 1 liter.

Total consumption of three households after using greywater = 3∗1=3 liters which is equal to the available quantity of water.

TestCase 2: Total consumption of a single household after using greywater = 1 +1+ ⌊21​⌋ = 1+0 = 1 liter which is less than the available quantity of water.

TestCase 3: Total consumption of a single household after using greywater = 1 +1+ ⌊21​⌋ = 1+0 = 1 liter.

Total consumption of two households after using greywater = 2∗1=2 liters which is more than the available quantity of water.

A – Save Water Save Life CodeChef Solution in C++14

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int h,x,y,c;
	    cin>>h>>x>>y>>c;
	    if(((x+y/2)*h)<=c)
	    {
	        cout<<"yes"<<endl;
	    }
	    else{
	        cout<<"no"<<endl;
	    }
	}
	
	return 0;
}

A – Save Water Save Life CodeChef Solution in Pyth 3

# cook your dish here
for i in range(int(input())):
    H,x,y,C=map(int,input().split())
    p=H*(x+(y//2))
    if p<=C:
        print("yes")
    else:
        print("no")

A – Save Water Save Life 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
	{
		// your code goes here
			Scanner sc= new Scanner(System.in);
		int n= sc.nextInt();
		for (int i=0;i<n;i++)
		{
		    int a= sc.nextInt();
		    int b= sc.nextInt();
		    int c=sc.nextInt();
		    int t=sc.nextInt();
		    int f=(a*b)+(a*(c/2));
		    if(f<=t)
		    System.out.println("yes");
		    else
		    System.out.println("no");
		}
	}
}
A – Save Water Save Life CodeChef Solution Review:

In our experience, we suggest you solve this A – Save Water Save Life CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the A – Save Water Save Life CodeChef Solution

Find on CodeChef

Conclusion:

I hope this A – Save Water Save Life CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *