Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
38385 23级徐泽厚 【S】T1 C++ 解答错误 0 26 MS 2628 KB 756 2025-10-03 16:34:49

Tests(0/10):


#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(){ //freopen("test.in","r",stdin); //freopen("test.out","w",stdout); 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])%998244353; } cout<<f[1]<<"\n"; return 0; }


测评信息: