Sir,where wrong in my code it gives wrong and run error

#include
#include<bits/stdc++.h>
#define INF 100000

using namespace std;
int main(){
long long int m,n;
cin>>m>>n;
long long int val[m];
long long int pro[m];
for( long long int i=0;i<m;i++){
val[i]=i+1;
}
for( long long int i=0;i<m;i++){
cin>>pro[i];
}

long long int dp[m+1][n+1];
for( long long int i=0;i<=m;i++){
dp[0][i]=INF;
}
for( long long int i=1;i<=n;i++){
dp[i][0]=0;
}
for( long long int i=1;i<=m;i++){
for( long long int j=1;j<=n;j++){
if(val[i-1]>j){

        dp[i][j]=dp[i-1][j];
    }
    else{
        dp[i][j]=min(dp[i-1][j],pro[i-1]+dp[i][j-val[i-1]]);
    }
}

}

cout<<dp[m][n];
}

Hi,

You are taking inputs in wrong way. The size of pro should be n. Read the question carefully.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.