2024-05-19 07:37:28 +00:00
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
const int MAXN = 105;
|
2024-06-09 06:40:50 +00:00
|
|
|
int dp[MAXN], obstacle[MAXN];
|
2024-05-19 07:37:28 +00:00
|
|
|
int main() {
|
|
|
|
int n;
|
|
|
|
cin >> n;
|
|
|
|
for (int i = 1; i <= n; i++) {
|
2024-06-09 06:40:50 +00:00
|
|
|
cin >> obstacle[i];
|
2024-05-19 07:37:28 +00:00
|
|
|
dp[i] = n - 1;
|
|
|
|
}
|
|
|
|
dp[1] = 0;
|
|
|
|
for (int i = 1; i <= n; i++) {
|
2024-06-09 06:40:50 +00:00
|
|
|
for (int j = i + 1; j <= i + obstacle[i] && j <= n; j++) {
|
2024-05-19 07:37:28 +00:00
|
|
|
dp[j] = min(dp[j], dp[i] + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << dp[n] << endl;
|
|
|
|
}
|