#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rrep(i, a, b) for(ll i=a; i>=b; i--)
#define vl vector<ll>
#define vpll vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define pll pair<ll, ll>
ll n, ans;
vl l, r, dp;
void f() {
cin >> n;
l.resize(n);
r.resize(n);
rep(i, 0, n) cin >> l[i] >> r[i];
dp.assign(n, 0);
dp[0]=1;
ans=1;
rep(i, 1, n){
dp[i]=1;
rrep(j, i-l[i]-1, 0){
if(r[j]+j+1<=i){
dp[i]=max(dp[i], 1+dp[j]);
// break;
}
}
ans=max(ans, dp[i]);
}
cout << ans << endl;
}
int main() {
int tc = 1;
// cin >> tc;
for (int i = 1; i <= tc; i++) {
// cout << '#' << i << endl;
f();
if (i != tc) cout << endl;
}
}
# | 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... |