Getting wrong answer in all test cases

#include
using namespace std;
int main() {
int n;
cin>>n;
int a[n+1];
for(int i=0;i<n;i++){
cin>>a[i];
}
int dp[n+1];
for (int i=0;i<n;i++){
dp[i]=100000000;
}
dp[0]=0;
for(int i=1;i<n;i++){
for(int j=0;j<i+1;j++){
if (a[j]>i){
dp[i]=min(dp[i],1+dp[j]);
}
}
}

cout<<dp[n];
return 0;

}
Getting the wrong answer in all test cases.

Hello @pranjal123
The implementation you used is not appropriate. I would suggest you to try it again and code it once more if you did it do let me know :smile:

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.