제출 #1133897

#제출 시각아이디문제언어결과실행 시간메모리
1133897huoiTrains (BOI24_trains)C++17
21 / 100
842 ms1114112 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 9e18 #define M 1000000007 void solve() { int n; cin >> n; vector<int> d(n + 1), x(n + 1); for (int i = 1; i <= n; i++) { cin >> d[i] >> x[i]; } vector<vector<int>> routes(n + 1); for (int i = 1; i <= n; i++) { for (int j = i + d[i]; j <= n; j += d[i]) { if (routes[i].size() == x[i] || d[i] == 0) break; routes[i].push_back(j); } } vector<int> dp(n + 1, 1); for (int i = n; i >= 1; i--) { for (int j : routes[i]) { dp[i] = (dp[i] + dp[j]) % M; } } cout << dp[1]; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); return 0; }
#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...