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>
#define endl "\n"
#define rs resize
#define pb push_back
#define gcd __gcd
const int mod = 1e9 + 7;
using namespace std;
void solve() {
int n; cin >> n;
vector<int> d(n), x(n);
for (int i = 0; i < n; ++i) cin >> d[i] >> x[i];
vector<int> v(n + 1, 0);
v[1] = 1;
for (int i = 1; i <= n; ++i) {
if (d[i - 1] > 0 && x[i - 1] > 0) {
int d_i = d[i - 1];
int x_i = x[i - 1];
for (int t = 1; t <= min(x_i, (n / d_i) + 2); ++t) {
int city = i + t * d_i;
if (city <= n) v[city] = (v[city] + v[i]) % mod;
else break;
}
}
}
int res = 0;
for (int i = 1; i <= n; ++i) res = (res + v[i]) % mod;
cout << res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int t; cin >> t;
// while (t--)
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... |