Submission #1111429

#TimeUsernameProblemLanguageResultExecution timeMemory
1111429gelastropodTrains (BOI24_trains)C++14
21 / 100
2100 ms10064 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector<pair<int, int>> vals; vector<int> dp; int ways(int n) { if (dp[n] != -1) return dp[n]; if (vals[n].first == 0 || n + vals[n].first >= (int)dp.size()) return dp[n] = 1; int ans = 1; for (int i = n + vals[n].first, t = 0; i < (int)dp.size() && t < vals[n].second; i += vals[n].first, t++) { ans += ways(i); ans %= 1000000007; } return dp[n] = ans; } signed main() { int N, a, b; cin >> N; dp = vector<int>(N, -1); for (int i = 0; i < N; i++) { cin >> a >> b; vals.push_back({a, b}); } cout << ways(0) << '\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...