not able solve code:
#include
using namespace std;
int main() {
int r,c;
cin>>r>>c;
int land[r][c];
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
cin>>land[i][j];
}
}
int dp[r+1][c+1];
for(int i=0;i<=r;i++){
for(int j=0;j<=c;j++){
dp[i][j] = 0;
}
}
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
dp[i][j] = max(dp[i-1][j],dp[i][j-1])+land[i-1][j-1];
}
}
cout<<dp[r][c];
return 0;
}