제출 #1051371

#제출 시각아이디문제언어결과실행 시간메모리
1051371nisanduuTrains (BOI24_trains)C++14
0 / 100
2100 ms8016 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll mod = 1e9 + 7; ll f(ll cr,ll n,map<ll,ll> &x,map<ll,ll> &d,vector<ll>&dp){ if(cr>n) return 0; ll am = 1; if(d[cr]==0) return am; if(dp[cr]!=-1) return dp[cr]; for(ll i=1;i<=x[cr];i++){ ll newDes = cr + i*d[cr]; am = (am + f(newDes,n,x,d,dp))%mod; } return dp[cr] = (am)%mod; } void solve(){ ll n; cin>>n; map<ll,ll> d,x; vector<ll> dp(1e5 + 10,-1); for(ll i=1;i<=n;i++){ ll a,b; cin>>a>>b; d[i]=a; x[i]=b; } ll ans = f(1,n,x,d,dp); cout<<ans<<endl; } int main() { solve(); 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...