Algorithm


 problem Link :  https://www.codechef.com/problems/CS2023_GIFT 

Problem

Om has  rupees. He wants to gift a laptop worth  rupees to his girlfriend.

We know that Om is the technical secretary of IIIT-A and has access to the Gymkhana funds of IIIT-A. Currently there are  rupees in the fund and Om can use the fund as much as he wants.

Find whether Om can gift his girlfriend a new laptop.

Input Format

  • The first and only line of input contains three space-separated integers , and  — the amount Om has, the price of the laptop, and the amount present in the Gymkhana fund respectively.

Output Format

For each input, output YES if Om can buy the laptop and NO otherwise.

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

Constraints

  • 1≤�,�,�≤103

Sample 1:

Input
 
Output
 
5 10 15
YES

Explanation:

Om uses 5 rupees from Gymkhana fund. So, the amount he has is 5+5=10 rupees. He can buy the laptop with cost 10 rupees.

Sample 2:

Input
 
Output
 
4 50 7
NO

Explanation:

Even if Om uses the whole Gymkhana fund, he won't be able to buy the laptop.

Code Examples

#1 Code Example with C Programming

Code - C Programming

 #include<bits/stdc++.h>
using namespace std;
using ll = long long;

void solve()
{
    int x,n,m;
    cin>>x>>n>>m;
    if(x+m>=n) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int TC = 1;
    //cin >> TC;
    //cin.ignore();
    while (TC--) solve();
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 50 7

Output

x
+
cmd
NO
Advertisements

Demonstration


CodeChef solution CS2023_GIFT  - The Gift Codechef solution in C,C++

Previous
CodeChef solution GCDQ - Gcd Queries Codechef solution in C,C++
Next
CodeChef solution WEEDING - Weeding Codechef solution in C,C++