Chef's Dream

All submissions for this problem are available.
The Chef is sleeping now. He tries to cook new kind of meals in his dream.
These meals are arranged in a row and numbered from 1 to N consecutively. For each meal i (1<=i<=N) there
is given one integer f(i) which denotes the time needed to cook it. Initially, all meals are uncooked. Each assistant
of The Chef (there are infinite number of them) can help him with cooking.
The abilities of all assistants are same. There can be at most one assistant cooking at each moment. He must choose some
continuous subsequence of meals with length K(any such subsequence can be chosen). And if there are uncooked meals in
it, he will cook all uncooked meals which has the minimum cooking time among uncooked meals in the chosen subsequence.
Nothing done to another meals.
The dream was so interesting that he tried to solve such a problem: What is the minimum number of assistants which can
cook all the meals assuming that each of them will cook at most once?
But since the bell rings and Chef's friends has come to visit him, he will wake up after 2 seconds. Your program
should calculate the answer before The Chef will come to himself.
Input
First line of input file contains two integers N (1<=N<=10^{5}) and K (1<=K<=N),
followed by a line containing N integers. The i^{th} integer denotes f(i)the cooking time of
meal number i (1<=f(i)<=10^{9})
Output
Print minimum number of assistans which can cook all the meals in one line.
Example
Input: 5 3 40 30 40 30 40 Output: 3
Explanation:
3 assistants are enough to cook all the meals. They can work in following schedule:
1^{st} assistant chooses interval [2,4] and cooks meals 2 and 4.
2^{nd} assistant chooses interval [1,3] and cooks meals 1 and 3.
3^{rd} assistant chooses interval [3,5] and cooks meal 5.
Other schedules can also be possible.
Author:  kamranmaharov 
Tester:  laycurse 
Editorial  http://discuss.codechef.com/problems/DREAM 
Tags  july12, kamranmaharov , simple, sorting 
Date Added:  10042012 
Time Limit:  0.261333 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, 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, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 