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 YES
, Yes
, yes
, and yES
are all considered the same.
Constraints
Sample 1:
5 10 15
YES
Explanation:
Om uses rupees from Gymkhana fund. So, the amount he has is rupees. He can buy the laptop with cost rupees.
Sample 2:
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
Output
Demonstration
CodeChef solution CS2023_GIFT - The Gift Codechef solution in C,C++