#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9e18
#define N 200005
void solve() {
int n;
cin >> n;
vector<int> d(n + 1), x(n + 1);
for (int i = 1; i <= n; i++) {
cin >> d[i] >> x[i];
}
vector<vector<int>> routes(n + 1);
for (int i = 1; i <= n; i++) {
for (int j = i + d[i]; j <= n; j += d[i]) {
if (routes[i].size() == x[i] || d[i] == 0) break;
routes[i].push_back(j);
}
}
vector<int> dp(n + 1, 1);
for (int i = n; i >= 1; i--) {
// cout << "stop " << i << " has: ";
for (int j : routes[i]) {
// cout << j << " ";
dp[i] += dp[j];
}
// cout << "\n";
}
cout << dp[1];
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |