Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Walk - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

Author:Dmytro Berezin
Tester:Mahbubul Hasan
Editorialist:Jingbo Shang

DIFFICULTY:

Cakewalk

PREREQUISITES:

Programming

PROBLEM:

Given a sequence of numbers W[0..N-1], find out a number S, such that S - i >= W[i] holds for all 0 <= i < N.

EXPLANATION:

It is easy to find out the choice of decreasing speed is to decrease it by 1 after each segment. So we can have the above problem.

After some transformations, the requirement is that S >= W[i] + i holds for all 0 <= i < N. Therefore, simply let S be the maximum of W[i]+i is the best choice.

AUTHOR'S AND TESTER'S SOLUTIONS:

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


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>