#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1E9 + 7;
int dp[100005], pref[100005][355];
signed main() {
int n, ans = 0; cin >> n;
dp[1] = 1;
for (int i = 1; i <= n; i++) {
int d, x; cin >> d >> x;
for (int j = 1; j <= 350; j++) {
if (i - j >= 0) pref[i][j] += pref[i - j][j];
dp[i] += pref[i][j];
}
if (d <= 350) {
pref[i][d] += dp[i];
pref[min(i + (x + 1) * d, n + 1)][d] -= dp[i];
} else {
for (int j = 1; j <= x && i + j * d <= n; j++) {
dp[i + j * d] += dp[i];
}
}
ans += dp[i];
}
cout << ans << '\n';
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... |