CL16BA - Editorial

PROBLEM LINK:

Practice
Contest

Author: Subham Das
Tester: Soumik Sarkar
Editorialist: Soumik Sarkar

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Basic knowledge of arrays or lists.

PROBLEM:

Determine the largest value in an array and compare it to a given value.

EXPLANATION:

An array of N values is provided along with a value M. The maximum value in the array needs to be determined, let’s call it maxval. The simple algorithm given below can be used to obtain maxval.

maxval = 0
for each val in N
    if maxval < val
        maxval = val

Now we have obtained maxval. The next step we perform is to check whether maxval is less than M. If it is less than M, we output “RESIGN” else we output the value of maxval.

if maxval < M
    print "RESIGN"
else
    print maxval

Complexity of this approach is \mathcal{O}(N).

AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.
Tester’s solution can be found here.