JASSIGNMENTS- Editorial

PROBLEM LINK:

Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4

Setter: Janmansh Agarwal
Tester: Takuki Kurokawa
Editorialist: Kanhaiya Mohan

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Janmansh has to submit 3 assignments for Chingari before 10 pm and he starts to do the assignments at X pm. Each assignment takes him 1 hour to complete. Can you tell whether he’ll be able to complete all assignments on time or not?

EXPLANATION:

The time required to complete 1 assignment is 1 hour. Thus, 3 hours are required to complete all 3 assignments.

In order to complete the assignments before 10 pm, Janmansh has to start before 10-3 = 7 pm. Thus, the answer is YES if X \leq 7. Otherwise, the answer is No.

TIME COMPLEXITY:

The time complexity is O(1) per test case.

SOLUTION:

Tester's Solution
#include <bits/stdc++.h>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        int x;
        cin >> x;
        if (x <= 7) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}
Editorialist's Solution
#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    int x;
	    cin>>x;
	    if(x <= 7){
	        cout<<"yEs";
	    }
	    else{
	        cout<<"nO";
	    }
	    cout<<endl;
	}
	return 0;
}