PSGRADE - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3

Author: Daanish Mahajan
Tester: Riley Borgard
Editorialist: Aman Dwivedi

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Recently, Chef’s College Examination has concluded. He was enrolled in 3 courses and he scored A, B, C in them, respectively. To pass the semester, he must score at least A_{min}, B_{min}, C_{min} marks in the respective subjects along with a cumulative score of at least T_{min}, i.e, A + B + C \ge T_{min}.

Given seven integers A_{min}, B_{min}, C_{min}, T_{min}, A, B, C, tell whether Chef passes the semester or not.

EXPLANATION:

Chef passes the semester if all the four conditions are satisfied:

  • Chef’s marks in course A should be greater than or equal to A_{min} i.e. A \ge A_{min}

  • Chef’s marks in course B should be greater than or equal to B_{min} i.e. B \ge B_{min}

  • Chef’s marks in course C should be greater than or equal to C_{min} i.e. C \ge C_{min}

  • Chef’scumulative score should be greater than or equal to T_{min} i.e. (A+B+C) \ge T_{min}

If all the four conditions are satisfied, Chef passes the semester hence print YES else NO.

TIME COMPLEXITY:

O(1) per test case

SOLUTIONS:

Setter
#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;
    }
}
Tester

#include <bits/stdc++.h>

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

void solve() {
    int a1, b1, c1, t, a, b, c;
    cin >> a1 >> b1 >> c1 >> t >> a >> b >> c;
    if(a1 <= a && b1 <= b && c1 <= c && a + b + c >= t) {
        cout << "YES\n";
    }else {
        cout << "NO\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int te;
    cin >> te;
    while(te--) solve();
}
Editorialist
#include<bits/stdc++.h>
using namespace std;

#define int long long

void solve()
{
	int a,b,c,t,a1,b1,c1;
	cin>>a>>b>>c>>t>>a1>>b1>>c1;

	if(a1>=a && b1>=b && c1>=c && a1+b1+c1>=t)
		cout<<"YES"<<"\n";
	else
		cout<<"NO"<<"\n";
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t;
	cin>>t;

	while(t--)
		solve();

return 0;
}