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
#define vec vector
const int MOD = 1e9 + 7;
int32_t main() {
int N;
cin >> N;
vec<int> D(N), X(N);
for(int i = 0; i<N; i++) {
cin >> D[i];
cin >> X[i];
}
vec<int> f(N, 1);
for(int i = N-2; i>=0; i--) {
if(D[i] == 0) continue;
for(int j = 1; j<=X[i] && i+(j*D[i]) < N; j++) {
f[i] += f[i+(j*D[i])];
f[i] %= MOD;
assert(i+(j*D[i]) < N);
}
}
cout << f[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... |