이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
int md=1e9+7;
int32_t main(){
//cerr<<"work\n";
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
sum2[1]=1;
for(int i=1;i<=n;i++){
//cerr<<i<<"\n";
int d,x;cin>>d>>x;
//x=min(x,(long long)1e5);
int tans=0;
for(int j=1;j<=s;j++){
if(i-j>=1)sum1[i][j]=sum1[i-j][j]+dp[i][j]+md,sum1[i][j]%=md;
tans+=sum1[i][j];
tans%=md;
}
//cerr<<tans<<" ";
tans+=sum2[i];
tans%=md;
//cerr<<tans<<"\n";
ans+=tans;
ans%=md;
if(d==0||x==0)continue;
if(d<=s){
if(i+d>n)continue;
dp[i+d][d]+=tans;
dp[i+d][d]%=md;
if(i+(x+1)*d<=n)dp[i+(x+1)*d][d]-=tans,dp[i+(x+1)*d][d]%=md;
}else{
for(int j=1;(j<=x)&&(i+j*d<=n);j++){
sum2[i+j*d]+=tans;
sum2[i+j*d]%=md;
}
}
}
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... |