PCJ18A - Editorial

PROBLEM LINK:

Practice
Contest

Author: Madhav Sainanee
Tester: Prakhar Gupta
Editorialist: Prakhar Gupta

DIFFICULTY:

CAKEWALK

PREREQUISITES:

None

PROBLEM:

Given N dishes, find out if there is atleast one dish with amount of secret ingredient \geq X

EXPLANATION:

We go over the amount of secret ingredient in all the N dishes. If we find a dish which has amount of secret ingredient more than or equal to X, we print ‘YES’.

One mistake participants did was break from the input loop once they found an A_i \geq X. This led to the remaining input of the current test case to be transferred to the next test case, leading to a Wrong Answer, or sometimes a Runtime Error verdict.

Complexity: The time complexity is O(N) per test case.

AUTHOR’S SOLUTION:

Author’s solution can be found here.

1 Like