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<vector<int>> ends(n+1);
vector<int> ans(n);
ans[0] = 1;
for (int i = 0; i < n; i++) {
int d, x;
cin >> d >> x;
int r = min(x+i, n);
ends[r].push_back(i);
}
int cur = 0;
for (int i = 0; i < n; i++) {
if (i > 0)
ans[i] = cur;
cur = (cur + ans[i]) % mod;
for (auto j : ends[i])
cur = (cur - ans[j] + mod) % 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... |