PBREV - Editorial

PROBLEM LINK:

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

Author: himanshu154
Tester: wasd2401
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

N judges review a problem proposal, each giving it a score between 1 and 10.
A problem proposal is good if every judge scores it strictly greater than 4.

Given the scores of each judge, decide whether a proposal is good or not.

EXPLANATION:

This task is more about implementing the process described in the statement than anything else.
One implementation method is described below.

Let \text{ct} be a variable denoting the number of judges who give the problem a “low” score, i.e, \leq 4.
Then, for each i = 1, 2, 3, \ldots, N in order:

  • If S_i \leq 4, add 1 to \text{ct}.
    • This can be checked using an if condition.
  • Otherwise, do nothing.

Finally, if \text{ct} \gt 0, some judge has given the proposal a low score (making the answer No), otherwise the answer is Yes.

There are other solutions too: for instance, you can compute the minimum element of S and check whether it’s \gt 4.

TIME COMPLEXITY:

\mathcal{O}(N) per testcase.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    n = int(input())
    s = list(map(int, input().split()))
    print('Yes' if min(s) >= 5 else 'No')