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>
#define int long long
using namespace std;
const int s=317;
int dp[200005][s+5];
int sum1[200005][s+5];
int sum2[200005];
int ans=0;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
sum2[1]=1;
for(int i=1;i<=n;i++){
int d,x;cin>>d>>x;
int tans=0;
for(int j=1;j<=s;j++){
if(i-j>=1)sum1[i][j]=sum1[i-j][j]+dp[i][j];
tans+=sum1[i][j];
}
//cerr<<tans<<" ";
tans+=sum2[i];
//cerr<<tans<<"\n";
ans+=tans;
if(d==0||x==0)continue;
if(d<=s){
dp[i+d][d]+=tans;
if(i+x*(d+1)<=n)dp[i+x*(d+1)][d]-=tans;
}else{
for(int j=1;j<=x&&i+j*d<=n;j++){
sum2[i+j*d]+=tans;
}
}
}
cout<<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... |