My issue
it work on example test case but when i submit the code , none of the hidden test cases work.
what I did was, i used 2 for loop to traverse the loop in the nested for look i added the k girls in the track and i put that in the max variable with an if,
explain what i did wrong if you can or give me the solution with explanation
Thanks in Advance
My code
#include <stdio.h>
int main(void) {
// your code goes here
int t;
scanf("%d", &t);
while(t--) {
int n, k, max = 0;
scanf("%d %d", &n, &k);
int g[n];
for(int i = 0; i < n; i++) {
scanf("%d ",&g[i]);
}
for(int i = 0;i < n - k; i++) {
int sum = 0;
// printf("%d", i);
for (int j = i; j < k+i; j++) {
sum += g[j];
}
if(max < sum) {
max = sum;
}
}
printf("%d\n", max);
}
return 0;
}
Problem Link: PROC18A Problem - CodeChef