제출 #1026262

#제출 시각아이디문제언어결과실행 시간메모리
1026262mareksbTrains (BOI24_trains)C++17
0 / 100
19 ms13252 KiB
#include <bits/stdc++.h> using namespace std; constexpr int N = 1e5+5; constexpr int mod = 1e9+7; int dp[N]{};//number of paths starting from i constexpr int d=320; int c[N+5][d]{};//sum dp given (start pos, step size) int main() { int n; cin>>n; int a[n+1],b[n+1]; for(int i=1;i<=n;i++){ cin>>a[i]>>b[i]; } for(int i=n;i>0;i--){ dp[i]=1; if(a[i]){ if(a[i]>=d){ for(int j=1;j<=b[i];j++){ int pos=i+j*a[i]; if(pos>n)break; dp[i]=(dp[i]+dp[pos])%mod; } } else{ int fin = min(i+a[i]*b[i],N); dp[i]=(dp[i]+c[i][a[i]]-c[fin][a[i]])%mod; } } //update c state for(int j=1;j<d;j++){ if(i-j<1)break; c[i-j][j]=(c[i][j]+dp[i])%mod; } } cout<<dp[1]<<' '; }
#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...