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;
#define int long long
signed main()
{
int N, a, b;
cin >> N;
vector<int> pref(N + 1, 0), dp(N, 1);
vector<pair<int, int>> vals;
for (int i = 0; i < N; i++)
{
cin >> a >> b;
vals.push_back({ a, b });
}
for (int i = N - 1; i >= 0; i--)
{
dp[i] = (1 + pref[i + 1] - pref[min(N, i + vals[i].second + 1)]) % 1000000007;
pref[i] = (dp[i] + pref[i + 1]) % 1000000007;
}
cout << dp[0] << '\n';
}
# | 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... |