Submission #1026136

#TimeUsernameProblemLanguageResultExecution timeMemory
1026136mareksbTrains (BOI24_trains)C++17
21 / 100
2041 ms2644 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5+5; const int mod = 1e9+7; int dp[N];//number of paths starting from i 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])continue; 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; } } cout<<dp[1]<<'\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...