제출 #1133894

#제출 시각아이디문제언어결과실행 시간메모리
1133894huoiTrains (BOI24_trains)C++17
8 / 100
828 ms1114112 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 9e18 #define N 200005 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--) { // cout << "stop " << i << " has: "; for (int j : routes[i]) { // cout << j << " "; dp[i] += dp[j]; } // cout << "\n"; } 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...