You are not logged in. Please login at www.codechef.com to post your questions!

×

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.

This question is marked "community wiki".

asked 14 Oct '16, 22:48

meooow's gravatar image

6★meooow ♦
7.3k720
accept rate: 48%

edited 07 Jun '17, 17:28

admin's gravatar image

0★admin ♦♦
19.8k350498541

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×15,852
×1,688
×862
×18
×1

question asked: 14 Oct '16, 22:48

question was seen: 462 times

last updated: 07 Jun '17, 17:28