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

SMHTD - Editorial

$
0
0

PROBLEM LINK:

http://www.codechef.com/SMHT2014/problems/SMHTD

DIFFICULTY:

EASY-MEDIUM

PREREQUISITES:

Longest Increasing subsequence.

EXPLANATION

For each element of modified sequence we have bi >= i (1<=i<=n) and we need to find the longest increasing subsequence of the original sequence ai and ai >= i. We keep such ai unchanged and other values can be changed into the value as their index. If we make another ci = ai - i, the answer is the equal to (n - the longest of the non-decreasing subsequence with no negative number) and for longest non-decreasing subsequence , a O(nlogn) solution can be used.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



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