PASS - Editorial

PROBLEM LINK:

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

Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

Chef wrote 5 exams, each scored out of 100.
He passes if he receives:

  • A score of at least 60 on \ge 2 exams.
  • A score of at least 30 on \ge 4 exams.

Did Chef pass?

EXPLANATION:

Simply implement what is asked for: count the number of exams in which Chef scored \ge 60 and check if it’s \ge 2, and also count the number of exams in which Chef scored \ge 30 and check if it’s \ge 4.

This can be implemented easily using a loop.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
for _ in range(int(input())):
    scores = list(map(int, input().split()))
    
    ct1, ct2 = 0, 0
    for i in range(5):
        if scores[i] >= 60:
            ct1 += 1
        if scores[i] >= 30:
            ct2 += 1
    
    print('Pass' if ct1 >= 2 and ct2 >= 4 else 'Fail')