#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define all(x) begin(x),end(x)
#define pb push_back
const int N=1e5+10,mod=1e9+7;
ll ways[N],suf[N],d[N],x[N];
void solve()
{
ll n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>d[i]>>x[i];
ways[i]=1;
}
suf[n+1]=0;
for(int i=n;i>=1;i--)
{
int j=min(n,i+x[i]);
ways[i] =(((suf[i+1]-suf[j+1])%mod)+mod)%mod;
ways[i] = (ways[i]+1)%mod;
suf[i]=(suf[i+1]+ways[i])%mod;
}
cout<<ways[1]%mod<<endl;
}
int main()
{
cin.tie(0);cout.tie(0);
ios::sync_with_stdio(0);
int t=1;
// cin>>t;
while(t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
5 ms |
3164 KB |
Output is correct |
6 |
Correct |
8 ms |
3420 KB |
Output is correct |
7 |
Correct |
10 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
2 ms |
2652 KB |
Output is correct |
12 |
Correct |
10 ms |
3420 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2652 KB |
Output is correct |
15 |
Correct |
9 ms |
3472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2908 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |