제출 #1125953

#제출 시각아이디문제언어결과실행 시간메모리
1125953quanquaiJobs (BOI24_jobs)C++20
0 / 100
2124 ms771884 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<int, int>> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i].first >> a[i].second; } int block_size = 320; const int mod = (int) 1e9 + 7; vector<int64_t> dp(n + 1, 0); vector<vector<int64_t>> diff(block_size + 5, vector<int64_t> (n + 1, 0)); dp[1] = 1; int64_t ans = 0; for (int i = 1; i <= n; i++) { int d = a[i].first, step = a[i].second; int64_t ways = dp[i]; for (int j = 1; j <= block_size; j++) { if (i - j >= 0) diff[j][i] += diff[j][i - j]; diff[j][i] %= mod; ways += diff[j][i]; ways %= mod; } ans += ways; ans %= mod; if (d == 0) continue; if (d >= block_size) { for (int cur = i + d, j = 1; (cur <= n && j <= step); j++, cur += d) { if (cur <= n) dp[cur] += dp[i]; } } else { if (i + d <= n) { diff[d][i + d] += ways; diff[d][i + d] %= mod; int last = i + (step + 1) * d; if (last <= n) { diff[d][last] -= ways; diff[d][last] %= mod; diff[d][last] += mod; diff[d][last] %= mod; } } } } 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...