# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051370 | deera | Trains (BOI24_trains) | C++14 | 2094 ms | 2652 KiB |
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;
const ll MOD = 1e9+7;
int main() {
ll n; cin >> n;
ll m = n + 100;
vector<ll> dp(m);
vector<ll> d(m), x(m);
for (ll i = 1; i <= n; i++) cin >> d[i] >> x[i];
for (ll i = 0; i < dp.size(); i++) dp[i] = 1;
for (ll i = n; i >= 1; i--) {
if (d[i] == 0) continue;
ll step = d[i];
for (ll j = i+step; j <= n && j <= i+step*x[i]; j+=step) {
dp[i] = (dp[j] + dp[i]) % MOD;
}
}
cout << dp[1] % MOD << endl;
return 0;
}
Compilation message (stderr)
# | 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... |