Submission #1049366

#TimeUsernameProblemLanguageResultExecution timeMemory
1049366YassirSalamaTrains (BOI24_trains)C++17
0 / 100
20 ms3676 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #ifdef IOI template<typename T> void dbg(const T&t){ cout<<t<<endl; } template<typename T,typename... Args> void dbg(const T& t,const Args&... args){ cout<<t<<" , "; dbg(args...); } #define dbg(...) cout<<"("<<#__VA_ARGS__<<"): ";dbg(__VA_ARGS__); #else #define dbg(...) 1337; #endif #define F first #define S second const int maxn=1e5+100; const int mod=1e9+7; signed main(){ int n; cin>>n; int dp[n+1]; memset(dp,0,sizeof(dp)); dp[1]=1; set<pair<int,int>> s; int cnt=0; for(int i=1;i<=n;i++){ while((*s.begin()).F==i){ cnt-=(*s.begin()).S; cnt%=mod; if(cnt<0) cnt+=mod; cnt%=mod; s.erase(s.begin()); } int d,x; cin>>d>>x; dp[i]+=cnt;//dp[i]=dp[i-1]+dp[i-2]+dp[i-3]+... dp[i]%=mod; cnt+=dp[i]; cnt%=mod; s.insert({i+x+1,dp[i]}); } int ans=0; for(int i=1;i<=n;i++){ ans+=dp[i]; ans%=mod; } printf("%lld\n",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...