# PROBLEM LINK:

*Author and Editorialist:* viresh_dev

# DIFFICULTY:

SIMPLE-EASY

# PREREQUISITES:

None

# PROBLEM:

Chef has been tested for Covid Positive. Based on Chef’s age(**A**), No. of beds available(**N**) and days to recover, we have to find whether the Chef could be saved or not if he has ‘**d**’ days left to get saved.

# QUICK EXPLANATION:

Just Check When a bed will get vacant and then find days remaining for the Chef to get saved. If it comes out to be more than days to recover print “Yes” else print “NO”.

# EXPLANATION:

Step wise solution as follows:

- Check whether any bed is vacant or not,

if vacant admit the Chef

If not, - Check whether a child is admitted or not,

Then, After 10 days Chef can be admitted

If not, - Check whether an adult is admitted or not,

Then, The Chef can be admitted after 14 days

If not, - Chef can only be admitted after 21 days
- After admitting Check if there are enough days left for the Chef to be cured

If true - print “YES”

else print “NO”

# TIME COMPLEXITY:

O(1)

# SOLUTIONS:

## Editorialist's Solution

```
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int t;
cin>>t;
while(t--)
{
ll a,n,d,x,y,z,min;
cin>>a>>n>>d>>x>>y>>z; // (x+y+z)<=n
// defining minimum days to recover
if(a<19)
min=10;
else if(a>18 && a<51)
min=14;
else
min=21;
ll diff =0;
if(x+y+z<n) // a bed is already vacant
{
if(d>=min)
cout<<"YES\n";
else
cout<<"NO\n";
}
else
{
diff = d-10; // there is a child on bed
if( diff < min)
cout<<"NO\n";
else
{
if(x>0)
cout<<"YES\n";
else
{
diff = diff-4; // when there is no child, checking for adult
if(diff >=min)
{
if(y>0)
cout<<"YES\n";
else
{
diff = diff - 7; //when there is no child or adult, checking for old
if(diff>=min)
cout<<"YES\n";
else
cout<<"NO\n";
}
}
else
cout<<"NO\n";
}
}
}
}
return 0;
}
```