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 <iostream>
#include <map>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
ll M=1000000007;
int N;
ll X[505],Y[505];
map<ll,ll> S;
map<pll,ll> DP;
ll ans;
int main(){
cin>>N;
for(int i=0;i<N;i++)
cin>>X[i]>>Y[i];
for(int i=N-1;i>=0;i--)
for(ll j=Y[i];j>=X[i];j--){
DP[{i,j}]=(S[j+1]+1)%M;
S[j]=(S[j]+DP[{i,j}])%M;
}
for(int i=0;i<N;i++)
ans=(ans+DP[{i,X[i]}])%M;
cout<<ans;
}
# | 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... |