Submission #1123225

#TimeUsernameProblemLanguageResultExecution timeMemory
1123225PwoTrains (BOI24_trains)C++17
21 / 100
2093 ms1828 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int m = 1e9 + 7; int n, dp[100005]; pair<int, int> a[100005]; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; dp[1] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j < i; j++) { if (a[j].first == 0) continue; int d = i - j; if (d % a[j].first == 0 && (d / a[j].first) <= a[j].second) dp[i] = (dp[i] + dp[j]) % m; } } int ans = 0; for (int i = 1; i <= n; i++) ans = (ans + dp[i]) % m; cout << ans; }
#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...