#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5+10;
const int B = 500;
int n;
int dp[N], d[N], x[N];
int pref[N];
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin >> n;
for(int i = 1;i <= n;i++){
cin >> d[i] >> x[i];
}
for(int i = 1;i <= n;i++){
dp[i] = 1;
}
for(int i = n;i >= 1;i--){
dp[i] += pref[i+1] - pref[min(n+1, i+x[i]+1)];
pref[i] = pref[i+1] + dp[i];
}
cout << dp[1] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |