What's wrong with my code why it is not working?

#include
#include <bits/stdc++.h>
using namespace std;

int mod=1e9+7;

int solve(vector arr,int n,int k){
int dp[n+1]={0};

dp[1]=1;
dp[2]=1;

for(int i=3;i<=n;i++){
	if(arr[i]==1){
		dp[i]=(dp[i-1])%mod;
	}
	else{
	int val=0;
	int start=0;
	if(i-k>=0) start=i-k;
	for(int j=start;j<i;j++){
		if(arr[j]!=1) val+=dp[j];
	}
	dp[i]=val%mod;
	}
}
return dp[n]%mod;

}

int main(){
int n,k;
cin >> n >> k;
vector arr(n+1);
for(int i=1;i<=n;i++){
cin >> arr[i];
}

cout << solve(arr,n,k);
return 0;

}