제출 #1111427

#제출 시각아이디문제언어결과실행 시간메모리
1111427gelastropodTrains (BOI24_trains)C++14
8 / 100
981 ms1896 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); } 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...