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;
}
1 Like

yes correct,

My solution:

cook your dish here

T = int(input()) total no of test case given by user (Janmansh)

X pm = time of start doing assig, complete before 10:00 PM

method1

if ((X+3) <= 10):

print(“yes”)

else:

print(“no”)

method2

for i in range(T):

X = int(input())


if ((10 - X) >= 3):
    print("yes")
else:
    print("no")