Passing Marks: PSGRADE

link: https://www.codechef.com/CU1PP0010/problems/PSGRADE

Recently, Chef’s College Examination has concluded. He was enrolled in 33 courses and he scored A,B,CA,B,C in them, respectively. To pass the semester, he must score at least Amin,Bmin,CminAmin,Bmin,Cmin marks in the respective subjects along with a cumulative score of at least TminTmin, i.e, A+B+C≥TminA+B+C≥Tmin.

Given seven integers Amin,Bmin,Cmin,Tmin,A,B,CAmin,Bmin,Cmin,Tmin,A,B,C, tell whether Chef passes the semester or not.

Input:

  • The first line will contain TT, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, seven integers Amin,Bmin,Cmin,Tmin,A,B,CAmin,Bmin,Cmin,Tmin,A,B,C each separated by aspace.

Output:

Output in a single line, the answer, which should be “YES” if Chef passes the semester and “NO” if 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).

Constraints

  • 1≤T≤1001≤T≤100
  • 1≤Amin,Bmin,Cmin,A,B,C≤1001≤Amin,Bmin,Cmin,A,B,C≤100
  • Amin+Bmin+Cmin≤Tmin≤300Amin+Bmin+Cmin≤Tmin≤300

Sample Input 1 

5
1 1 1 300 2 2 2
3 2 2 6 2 2 2
2 3 2 6 2 2 2
2 2 3 6 2 2 2
100 100 100 300 100 100 100

Sample Output 1 

NO
NO
NO
NO
YES

Explanation

TestCase 1: Chef is passing in all the subjects individually but his total score (2+2+2=62+2+2=6) is much below the required threshold of 300300 marks. So Chef doesn’t pass the semester.

TestCase 2: Chef’s score in the first subject is less than the threshold, so he doesn’t pass the semester.

TestCase 3: Chef’s score in the second subject is less than the threshold, so he doesn’t pass the semester.

TestCase 4: Chef’s score in the third subject is less than the threshold, so he doesn’t pass the semester.

TestCase 5: Chef is passing in all the subjects individually and also his total score is equal to the required threshold of 300300 marks. So Chef passes the semester.

See also  Longest Subarray: CHEFSUB(Assignment)

Solution:

// By progies.in
#include<bits/stdc++.h>

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

using namespace std;
const int maxt = 100, minv = 1, maxv = 100, maxtt = 300;

int main()
{
    int t; cin >> t;
    int cnt = 0;
    int a, b, c, tot, sa, sb, sc;
    while(t--){
        cin >> a >> b >> c >> tot >> sa >> sb >> sc;
        bool can = (sa >= a && sb >= b && sc >= c && sa + sb + sc >= tot);
        string ans = can ? "YeS" : "nO";
        cout << ans << endl;
    }
}