All submissions for this problem are available.
On a wall of a bus station, there is enough space to post N number of film posters in a single row. A Production company 'A' posted in all the N slots with different posters of same size. Later, it became an issue for other companies due to lack of space. All companies reached upon an agreement so that no company can post more than 'K' consecutive posters. So company 'A' decided to remove some of the posters. Each poster yields different profit to company. Find the maximum possible profit that the company 'A' can make without violating the agreement. 1 <= n,K <= 10^5 0 <= Pi <= 2*10^9 i/p format: N K P1 P2 .. Pn o/p format: Result followed by a newline character. Sample Input: 6 2 1 2 3 1 6 10 Sample Output: 21 reason : - 2 3 - 6 10 2+3+6+10 = 21
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.