Submission #1047158

#TimeUsernameProblemLanguageResultExecution timeMemory
1047158KarolZTrains (BOI24_trains)C++14
16 / 100
31 ms35092 KiB
#include<iostream> #include<vector> #include<map> #pragma GCC optimize "Ofast" using namespace std; typedef long long ll; const ll mod=1000000007; map<int,ll>m[100010];//pozycja,o ile skok, ile dodac map<int,ll>::iterator it; 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=0; if(i==1)akt++; for(it=m[i].begin();it!=m[i].end();it++){ akt+=it->second; if(i+it->first<=n)m[i+it->first][it->first]+=it->second%mod; else break; } cin>>v1>>v2; 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; 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...