This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define debug(...)
#endif
const int md = (int) 1e9 + 7;
void add(int& x, int y) {
x += y;
if (x >= md) {
x -= md;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> d(n), x(n);
for (int i = 0; i < n; ++i) {
cin >> d[i] >> x[i];
}
vector<int> dp(n);
for (int i = n - 1; i >= 0; --i) {
dp[i] = 1;
if (d[i] > 0) {
for (int j = 1; j <= x[i] && i + d[i] * j < n; ++j) {
add(dp[i], dp[i + d[i] * j]);
}
}
}
cout << dp[0] << '\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... |