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
int mod= 1e9+7;
int32_t main()
{
int n;
cin>>n;
vector<pair<int,int>> city(n);
vector<int> ans(n);
for(int i=0;i<n;i++)
{
int a,b;
cin>>a>>b;
city[i]={a,b};
}
ans[0]=1;
for(int i=0;i<n;i++){
if(i+1<n)
ans[i+1]=(ans[i+1]+ans[i])%mod;
if(i+city[i].second+1<n){
ans[i+city[i].second+1]=(ans[i+city[i].second+1]-ans[i])%mod;
}
}
int sum=0;
for(int i=0;i<n;i++){
sum+=ans[i]%mod;
}
//0 2 1
return 0;
}
# | 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... |