提交时间:2025-10-03 16:09:21

运行 ID: 38375

#include <bits/stdc++.h> #define int long long using namespace std; int n,f[200005]; pair<int,int> a[200005]; stack<pair<int,int> > st; signed main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>n; for (int i=1;i<=n;i++){ cin>>a[i].first>>a[i].second; } sort(a+1,a+n+1); f[n+1]=1; for (int i=n;i>=1;i--){ int t=a[i].first+a[i].second; int nxt=i+1; while (!st.empty() and t>a[st.top().first].first){ nxt=st.top().second; st.pop(); } st.push({i,nxt}); f[i]=(f[i+1]+f[nxt])%99824453; } cout<<f[1]<<"\n"; return 0; }