fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,n,k;
  6. cin>>t;
  7. while(t--)
  8. {
  9. cin>>n>>k;
  10. int a[n],max=INT_MIN;
  11. for(int i=0;i<n;i++)
  12. cin>>a[i];
  13. for(int i=0;i<n-k;i++)
  14. {
  15. int c=i,temp=0;
  16. for(int j=0;j<k;j++)
  17. {
  18. temp=temp+a[c];
  19. c++;
  20. }
  21. if(max<temp)
  22. max=temp;
  23. }
  24. cout<<max<<endl;
  25. }
  26. }
Runtime error #stdin #stdout 0s 4344KB
stdin
Standard input is empty
stdout
Standard output is empty