LIS with atmost k exceptions allowed

Revision en2, by rain_0, 2019-12-31 01:05:45

Given sequence of N integers, find the longest subsequence whose elements are ordered in an increasing order. Up to k exceptions that means at most k times, the next number in the sequence is smaller than previous one. Output should be the length of the longest such subsequence. In particular the question is a variant of LIS problem where at most k exceptions (restarts) are allowed.

Constraints:

3 <= N <= 10^6

1 <= K <= max{N-1,2000}

1 <= s[i] <=10^7

Time: 3 sec

Memory: 64 MB

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English rain_0 2019-12-31 01:05:45 0 (published)
en1 English rain_0 2019-12-31 01:05:20 548 Initial revision (saved to drafts)