EXPERT - Editorial

PROBLEM LINK:

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

Author: Kanhaiya Mohan
Tester: Tejas Pandey
Editorialist: Nishank Suresh

DIFFICULTY:

561

PREREQUISITES:

None

PROBLEM:

A problemsetter has proposed X problems and Y out of them were approved. Is Y at least 50\% of X?

EXPLANATION:

It is enough to directly check the condition: for Y to be at least 50\% of X, Y must satisfy the inequality 2Y \geq X.

So,

  • The answer is “Yes” if 2Y \geq X
  • The answer is “No” otherwise

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    x, y = map(int, input().split())
    print('Yes' if 2*y >= x else 'No')
1 Like