This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |