Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
28175 | liuyile | 【BJ】T3 | C++ | 运行超时 | 50 | 3052 MS | 5168 KB | 893 | 2024-04-04 17:52:10 |
#include <bits/stdc++.h> using namespace std; #define int long long #define lc(x) (x<<1) #define rc(x) (x<<1|1) const int N=1.25e5+30; int l[N],r[N]; int n; const int M=1e9+7; int rk[N],f[N]; signed main(){ ios::sync_with_stdio(0); // freopen("schooldays.in","r",stdin); // freopen("schooldays.out","w",stdout); cin>>n; f[0]=1; for(int i=1;i<=n;i++){ cin>>l[i]>>r[i]; int L=0,R=1e9; for(int j=i;j>=1;j--){ L=max(L,l[j]),R=min(R,r[j]); if(L>R||i-j+1>R)break; if(i-j+1<L)continue; if(rk[j-1]+1>rk[i])rk[i]=rk[j-1]+1,f[i]=f[j-1]; else if(rk[j-1]+1==rk[i])f[i]=(f[i]+f[j-1])%M; } } if(rk[n]==0)cout<<-1<<endl; else cout<<rk[n]<<" "<<f[n]<<endl; cout.flush(); return 0; } /* 9 1 4 2 5 3 4 1 5 1 1 2 5 3 5 1 3 1 1 */