Submission #1084747

#TimeUsernameProblemLanguageResultExecution timeMemory
1084747zxciganTrains (BOI24_trains)C++17
21 / 100
1211 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long const int N = 2e5; const int mod = 1e9 + 7; int dp[N]; vector<int> g[N]; int32_t main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // LOCAL ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; ++i) { int x, d; cin >> d >> x; if (x && d) { for (int j = 1; j <= x; ++j) { if (i + d * j > n) break; // if (i == 1) cout << i << ' ' << d << ' ' << j << ' ' << i + d * j << '\n'; g[i + d * j].push_back(i); } } } dp[1] = 1; int s = 0; for (int i = 1; i <= n; ++i) { for (auto to : g[i]) { (dp[i] += dp[to]) %= mod; } (s += dp[i]) %= mod; } // cout << g[2].size() << '\n'; cout << s << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...