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;
using ll = long long;
#define int long long
const int N = 2e5;
const int mod = 1e9 + 7;
const int B = 335;
int dp[N];
int32_t main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
dp[1] = 1;
int s = 0;
vector<vector<int>> add (B + 1, vector<int> (B + 1, 0));
set<array<int,2>> st;
vector<int> pref (n + 3);
int C = 0;
for (int i = 1; i <= n; ++i) {
int x, d;
cin >> d >> x;
if (i != 1) dp[i] = C;
if (x && d) {
(C += dp[i]) %= mod;
(pref[min (n + 1, i + x * d)] += dp[i]) %= mod;
}
C -= pref[i];
if (C < 0) C += mod;
(s += dp[i]) %= mod;
}
// cout << dp[3] << '\n';
cout << s << '\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... |