# DEVSPORTS - Editorial

Setter: Devendra Singh
Testers: Lavish Gupta, Tejas Pandey
Editorialist: Ajit Sharma Kasturi

CAKEWALK

None

### PROBLEM:

Devandra is on a trip and initially had Z rupees at the start of the trip and already has spent Y rupees from it. He wants to try three kinds of sports which have costs A, B and C rupees. If Devandra can try all the sports atleast once, we need to output YES, else we need to output NO.

### EXPLANATION:

• Initially Devandra has Z rupees. Out of that, Y rupees has already been spent. Now, the current amount he has will be Z-Y rupees.

• The minimum cost to try all the sports will be A+B+C rupees.

• Therefore, if Z-Y \geq A+B+C, we output YES, else we output NO.

### TIME COMPLEXITY:

O(1) for each test case.

### SOLUTION:

Editorialist's solution
``````#include <bits/stdc++.h>
using namespace std;

int main()
{
int tests;
cin >> tests;
while (tests--)
{
int z, y, a, b, c;
cin >> z >> y >> a >> b >> c;

if (z - y >= a + b + c)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
return 0;
}
``````
Tester's solution
``````// validating input
#include <bits/stdc++.h>
using namespace std;
#define ll long long

/*
------------------------Input Checker----------------------------------
*/

long long readInt(long long l,long long r,char endd){
long long x=0;
int cnt=0;
int fi=-1;
bool is_neg=false;
while(true){
char g=getchar();
if(g=='-'){
assert(fi==-1);
is_neg=true;
continue;
}
if('0'<=g && g<='9'){
x*=10;
x+=g-'0';
if(cnt==0){
fi=g-'0';
}
cnt++;
assert(fi!=0 || cnt==1);
assert(fi!=0 || is_neg==false);

assert(!(cnt>19 || ( cnt==19 && fi>1) ));
} else if(g==endd){
if(is_neg){
x= -x;
}

if(!(l <= x && x <= r))
{
cerr << l << ' ' << r << ' ' << x << '\n';
assert(1 == 0);
}

return x;
} else {
assert(false);
}
}
}
string ret="";
int cnt=0;
while(true){
char g=getchar();
assert(g!=-1);
if(g==endd){
break;
}
cnt++;
ret+=g;
}
assert(l<=cnt && cnt<=r);
return ret;
}
long long readIntSp(long long l,long long r){
}
long long readIntLn(long long l,long long r){
}
}
}

/*
------------------------Main code starts here----------------------------------
*/

const int MAX_T = 10;
const int MAX_N = 100000;
const int MAX_Q = 100000;
const int MAX_val = 1000000000;
const int MAX_SUM_N = 100000;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int sum_n = 0;
int max_n = 0;
int yess = 0;
int nos = 0;
int total_ops = 0;
ll p = 1000000007;
ll sum_nk = 0 ;

void solve()
{
int z = readIntSp(10000 , 100000) ;
int y = readIntSp(0 , z) ;

int a = readIntSp(100 , 5000) ;
int b = readIntSp(100 , 5000) ;
int c = readIntLn(100 , 5000) ;

int s = y+a+b+c ;
cerr << z-s << endl ;

if(z-s >= 0)
cout << "YES\n" ;
else
cout << "NO\n" ;
return ;
}

signed main()
{
//fast;
#ifndef ONLINE_JUDGE
freopen("inputf.txt" , "r" , stdin) ;
freopen("outputf.txt" , "w" , stdout) ;
freopen("error.txt" , "w" , stderr) ;
#endif

int t = 1;

for(int i=1;i<=t;i++)
{
solve() ;
}

assert(getchar() == -1);
// assert(sum_n <= MAX_SUM_N);

cerr<<"SUCCESS\n";
cerr<<"Tests : " << t << '\n';
// cerr<<"Sum of lengths : " << sum_n << '\n';
// cerr<<"Maximum length : " << max_n << '\n';
// cerr << "Sum of product : " << sum_nk << '\n' ;
// cerr<<"Total operations : " << total_ops << '\n';
// cerr<<"Answered yes : " << yess << '\n';
// cerr<<"Answered no : " << nos << '\n';
}

``````

Please comment below if you have any questions, alternate solutions, or suggestions.