Why my code is giving run error?

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

long long int solve(int n){
long long int dp[n+1]={0};
dp[0]=0;

for(int i=1;i<=n;i++){
	int val=dp[i/2]+dp[i/3]+dp[i/4];
	dp[i]=max(i,val);
}

return dp[n];

}

int main() {
int n;
cin >> n;
cout << solve(n);
return 0;
}