# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1261905 | CrabCNH | Trains (BOI24_trains) | C++20 | 2093 ms | 2632 KiB |
#include <bits/stdc++.h>
#define task "BriantheCrab"
#define int long long
#define pii pair <int, int>
#define fi first
#define se second
#define szf sizeof
#define sz(s) (int)((s).size())
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
template <class T> void minimize (T &t, T f) {if (t > f) t = f;}
template <class T> void maximize (T &t, T f) {if (t < f) t = f;}
const int maxN = 2e5 + 5;
const int inf = 1e18 + 7;
const int mod = 1e9 + 7;
// khong tu code thi khong kha len duoc dau
// biet sol roi thi tu lam not di
int d[maxN], x[maxN];
int dp[maxN];
void solve () {
int n;
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> d[i] >> x[i];
}
dp[1] = 1;
for (int i = 1; i <= n; i ++) {
if (d[i] == 0) {
continue;
}
for (int t = 1; t <= x[i]; t ++) {
if (i + t * d[i] > n) {
break;
}
(dp[i + t * d[i]] += dp[i]) %= mod;
}
}
int res = 0;
for (int i = 1; i <= n; i ++) {
(res += dp[i]) %= mod;
}
cout << res;
return;
}
signed main () {
cin.tie (nullptr) -> sync_with_stdio (false);
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int t = 1;
//cin >> t;
while (t --) {
solve ();
}
return 0;
}
// thfv
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... |