text: Here is the question :-Expected Profits -20 90 -30 -20 80 -70 -60 125If formatT formatA single integer P, indicating the maximum possible profit.Test Data:You may assume that 1 ≤ N ≤ 1000000 and 1 ≤ K ≤ N. You may further assume that in 50% of the inputs N≤ 5000.Example:We illustrate the input and output format using the above example:Sample Input 1:
  8 3-2090-30-2080-70-60125 Sample Output 1:
  120Sample Input 2:
  8 1-2090-30-2080-70-60125 Sample Output 2:
  125
  And here is my solution :-
  But i am getting wrong answer for 6 test case out of 10 . Could anybody give example where my programme is wrong or correct my code ?But i am getting wrong answer for 6 test case out of 10 . Could anybody give example where my programme is wrong or correct my code ?Code:
  #include<iostream>
  using namespace std;
  int main( ) {
  int i,j,n,k,stations[100000],summed[100000],sum=0,msum=0;
  cin>>n>>k;
  for (i=1;i<=n;i++) {
  cin>>stations[i];
  sum+=stations[i];
  summed[i]=sum;
  }
  sum=0;
  summed[0]=0;
  for (i=1;i<=n-k+1;i++) {
  for (j=i+k-1;j<=n;j++) {
  sum=summed[j]-summed[i-1];
  if (msum<sum) msum=sum;
  }
  }
  cout<<msum;
  system("PAUSE");
  }