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;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(a,b) for(int a = 0; a < (b); ++a)
#define all(t) t.begin(), t.end()
#define pb push_back
const int N = 1e5+5, INF = 2e9+54321, mod = 1e9+7;
const ll INF_L = (ll)2e18+54321;
int n, wyn;
int D[N], X[N], dp[N];
void solve()
{
cin >> n;
rep(i,n) cin >> D[i] >> X[i];
wyn = 0, dp[0] = 1;
rep(i,n)
{
wyn += dp[i];
for(int j = 1; j <= X[i] and i+j*D[i] < n; ++j) dp[i+j*D[i]] = (dp[i+j*D[i]]+dp[i]) % mod;
}
cout << wyn << '\n';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int T = 1;
//cin >> T;
while(T--) solve();
return 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... |