Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Apples and Oranges CodeChef Solution

Problem – Apples and Oranges CodeChef Solution

Bob has X rupees and goes to a market. The cost of apples is Rs. A per kg and the cost of oranges is Rs. B per kg.

Determine whether he can buy at least 1 kg each of apples and oranges.

Input Format

  • The first line of input will contain an integer X, the amount of money Bob has.
  • The second line of input contains two space-separated integers A and B, the cost per kg of apples and oranges respectively.

Output Format

Print a single line containing Yes if Bob can buy the fruits and No otherwise.

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

Constraints

  • 1≤X,A,B≤10^5

Subtasks

  • Subtask 1 (100 points):
    • Original constraints.

Sample 1:

Input: 14
2 2
Output: Yes

Explanation:

The cost of buying 1 kg each of apple and orange is 2+2=4. Since Bob has more than 4 rupees, the answer will be Yes.

Sample 2:

Input: 1
1 1
Output: No

Explanation:

Bob can only buy either 1 kg of apples or 1 kg of oranges with 1 rupee, hence the answer is No.

Sample 3:

Input: 5
3 2
Output: Yes

Explanation:

The cost of buying 1 kg each of apple and orange is 3+2=5. Since Bob has exactly 5 rupees, the answer will be Yes.

Sample 4:

Input: 10000
5000 6000
Output: No

Explanation:

The cost of buying 1 kg each of apple and orange is 5000+6000=11000. Since Bob has only 10000 rupees, the answer will be No.

Apples and Oranges CodeChef Solution in Pyth 3

x=int(input())
a,b=map(int,input().split())
a=a+b
print('YES' if a<=x else 'NO')


Apples and Oranges CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() 
{
	int x,a,b;
	cin>>x>>a>>b;
	if(x>=(a+b))
	cout<<"Yes"<<endl;
	else 
	cout<<"no"<<endl;
	return 0;
}

Apples and Oranges CodeChef 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 a=sc.nextInt();
	    int b=sc.nextInt();
	    int c=sc.nextInt();
	    if((b+c)>a)
	    {
	        System.out.println("no");
	    }
	    else
	    System.out.println("yes");
	}
}
Apples and Oranges CodeChef Solution Review:

In our experience, we suggest you solve this Apples and Oranges 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 Apples and Oranges CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Apples and Oranges 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 *