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>
using namespace std;
const int M = 1e6 + 1, mod = 1e9 + 7;
int fen[M+1];
void modify(int p,int x)
{
p++;
while (p<=M)
{
fen[p]+=x;
fen[p]%=mod;
p+=p&-p;
}
}
int get(int p)
{
int ans=0;
p++;
while (p)
{
ans+=fen[p];
ans%=mod;
p-=p&-p;
}
return ans;
}
int main()
{
int n;
cin>>n;
int a[n],b[n];
set<int> se;
for (int i=0;i<n;i++)
{
cin>>a[i]>>b[i];
for (int j=a[i];j<=b[i];j++)
se.insert(j);
}
map<int,int> mp;
for (int i:se)
mp[i]=mp.size()+1;
modify(0,1);
for (int i=0;i<n;i++)
{
a[i]=mp[a[i]],b[i]=mp[b[i]];
for (int j=b[i];j>=a[i];j--)
modify(j,get(j-1));
}
cout<<get(M)-1<<endl;
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... |