Submission #1055711

#TimeUsernameProblemLanguageResultExecution timeMemory
1055711ezzzayTrains (BOI24_trains)C++14
21 / 100
980 ms1048720 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define int long long #define ss second #define pb push_back const int N=3e5+5; const int mod=1e9+7; int cnt[N]; std::vector<int>v[N],vc[N]; int dp[N]; signed main(){ int n; cin>>n; for(int i=1;i<=n;i++){ int d,x; cin>>d>>x; if(d==0)continue; for(int j=1;j<=x;j++){ if(i+d*j>n)break; v[i].pb(i+d*j); vc[i+d*j].pb(i); } } dp[1]=1; for(int i=2;i<=n;i++){ for(auto b:vc[i]){ dp[i]+=dp[b]; dp[i]%=mod; } } int ans=0; for(int i=1;i<=n;i++){ ans+=dp[i]; ans%=mod; } cout<<ans; }
#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...