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 suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
void solve(){
ll n;
cin>>n;
ll l[n+5],r[n+5],dp[n+5]={};
for(ll i=1;i<=n;i++){
cin>>l[i]>>r[i];
l[i]=min(i-1,l[i]);
r[i]=min(n-i,r[i]);
}
dp[0]=0;
ll mx=0;
for(int i=1;i<=n;i++){
ll mx1=0;
for(int j=i-l[i]-1;j>=1;j--) if(j+r[j]<i) mx1=max(mx1,dp[j]);
dp[i]=mx1+1;
// co i<<' '<<dp[i]<<' '<<i-l[i]-1<<'\n';
mx=max(mx,dp[i]);
}
co mx;
}
int main()
{
suiii
int _=1;
// cin>>_;
while(_--) solve();
return 0;
}
# | 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... |