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 <iostream>
#include <algorithm>
using namespace std;
int N;
int D[10005];
int X[10005];
//int N=7; int D[10005]={1,2,2,0,2,2,2}; int X[10005]={2,1,1,2,100,100,100};
long long dp[10005];
int mod=1000000007;
int main(){
cin >> N;
for (int i=0;i<N;i++) cin>>D[i]>>X[i];
for (int i=N-1; i>=0; i--){
dp[i]++;
if (D[i]==0) continue;
for (int j=1; j<=X[i]&&i+j*D[i]<N; j++) dp[i]=(dp[i]+dp[i+j*D[i]])%mod;
//cout << i << dp[i] << i+D[i]*X[i] << '\n';
}
cout << dp[0];
}
# | 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... |