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 itn long long
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e5+5;
int l[N],r[N];
int dp[N];
signed main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>l[i]>>r[i];
}
int ans=0;
for(int i=1;i<=n;i++){
dp[i]=1;
for(int j=0;j<i;j++){
if(r[j]+j>=i)continue;
if(i-l[i]<=j)continue;
dp[i]=max(dp[i],dp[j]+1);
}
ans=max(ans,dp[i]);
}
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... |