Chefland Visa: VISA



Ash is trying to get visa to Chefland. For the visa to be approved, he needs to satisfy the following three criteria:

  • Solve at least x1x1 problems on Codechef.
  • Have at least y1y1 current rating on Codechef.
  • Make his last submission at most z1z1 months ago.

You are given the number of problems solved by Chef (x2x2), his current rating (y2y2) and the information that he made his last submission z2z2 months ago. Determine whether he will get the visa.


  • The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
  • The first and only line of each test case contains six space-separated integers x1x1, x2x2, y1y1, y2y2, z1z1 and z2z2.


For each test case, print a single line containing the string "YES" if Chef will get the visa or "NO" if he will not.

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


  • 1≤T≤5,0001≤T≤5,000
  • 20≤x1,x2≤5020≤x1,x2≤50
  • 1,900≤y1,y2≤2,1001,900≤y1,y2≤2,100
  • 1≤z1,z2≤61≤z1,z2≤6

Sample Input 1 

20 50 2100 1900 6 6
50 20 1900 1900 5 5
20 20 1900 1900 1 6
27 27 1920 1920 3 3

Sample Output 1 



Example case 1: Chef’s rating is less than the minimum required rating.

Example case 2: Chef has solved a smaller number of problems than the minimum required number.

Example case 3: Chef’s last submission was made before the allowed period.

Example case 4: All three conditions are met.


# define pb push_back 
#define pii pair<int, int>
#define mp make_pair
# define ll long long int

using namespace std;
const int maxt = 5000;
const string newln = "\n", space = " ";
int main()
    int t, x, x1, y, y1, z, z1; cin >> t; 
        cin >> x >> x1 >> y >> y1 >> z >> z1;
        string ans = (x1 >= x && y1 >= y && z1 <= z) ? "YeS" : "No";
        cout << ans << endl;            

* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first.