Submission #1047271

#TimeUsernameProblemLanguageResultExecution timeMemory
1047271KarolZTrains (BOI24_trains)C++14
100 / 100
186 ms268272 KiB
#include<iostream> #include<vector> using namespace std; typedef long long ll; const ll mod=1000000007,skrt=330; ll m[100010][skrt+10]; ll mm[100010]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,v1,v2,wyn=0,akt; cin>>n; for(int i=1;i<=n;i++){ akt=mm[i]; if(i==1)akt++; for(int j=1;j<=skrt;j++){ akt+=m[i][j]; if(i+j<=n)m[i+j][j]+=m[i][j]; } cin>>v1>>v2; if(v1<=skrt){ if(i+v1<=n)m[i+v1][v1]+=akt%mod; if(i+v1*(v2+1)<=n&&i+v2<=n)m[i+v1*(v2+1)][v1]-=akt%mod-mod; } else{ for(int j=i+v1;j<=min(n,i+v1*v2);j+=v1)mm[j]+=akt%mod; } wyn+=akt; wyn%=mod; } cout<<wyn; 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...