Submission #1224118

#TimeUsernameProblemLanguageResultExecution timeMemory
1224118s3yoonparkTrains (BOI24_trains)C++20
8 / 100
113 ms134420 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MOD = 1E9 + 7; int dp[100005], pref[100005][355]; signed main() { int n, ans = 0; cin >> n; dp[1] = 1; for (int i = 1; i <= n; i++) { int d, x; cin >> d >> x; for (int j = 1; j <= 350; j++) { if (i - j >= 0) pref[i][j] += pref[i - j][j]; dp[i] += pref[i][j]; } if (d <= 350) { pref[i][d] += dp[i]; pref[min(i + (x + 1) * d, n + 1)][d] -= dp[i]; } else { for (int j = 1; j <= x && i + j * d <= n; j++) { dp[i + j * d] += dp[i]; } } ans += dp[i]; } cout << ans << '\n'; 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...