Submission #1234988

#TimeUsernameProblemLanguageResultExecution timeMemory
1234988ThommyDBTrains (BOI24_trains)C++20
100 / 100
504 ms296468 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int MOD = 1e9+7; signed main(){ int n; cin >> n; vector<int> d(n+1), x(n+1); for(int i = 0; i < n; i++){ cin >> d[i] >> x[i]; } vector<int> ans(n, 0); ans[0]=1; int totalans = 0; vector<vector<int>> pref(n+5, vector<int>(370)); for(int i = 0; i < n; i++){ for (int j = 0; j <= 360; j++) { if (i-j >= 0)pref[i][j]+=pref[i-j][j]; pref[i][j]%= MOD; ans[i] +=pref[i][j]; ans[i] %= MOD; } if(d[i]>360){ for(int j = 1; j <= x[i]; j++){ int k = i+d[i]*j; if(k>=n)break; ans[k]+=ans[i]; ans[k]%=MOD; } } else{ pref[i][d[i]]+= ans[i]; pref[i][d[i]] %= MOD; int r = min(i+(x[i]+1)*d[i],n); pref[r][d[i]] +=MOD-ans[i]; pref[r][d[i]] %= MOD; } totalans+=ans[i]; totalans%=MOD; } cout << totalans << "\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...