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;
int mod = 1e9+7;
int main() {
int n;
cin >> n;
vector<int> x(n), ans(n);
ans[0] = 1;
for (int i = 0; i < n; i++)
cin >> x[i] >> x[i];
vector<int> diff(n+1);
int cur = 0;
for (int i = 0; i < n; i++) {
if (i > 0)
ans[i] = cur;
cur = (cur + ans[i] + diff[i]) % mod;
(diff[min(i+x[i], n)] += mod - ans[i]) %= mod;
}
cout << accumulate(ans.begin(), ans.end(), 0LL) % mod << endl;
}
# | 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... |