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>
#define I inline void
using ll = long long ;
using ld = long double ;
using namespace std ;
const int N = 1e4 + 7 , mod = 1e9 + 7 ;
// how interesting!
int n;
map<ll , ll> dp ;
ll ans = 0 ;
int main(){
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
//freopen("in.in" , "r" , stdin) ;
cin >> n ;
dp[0] = 1ll ;
for(int i = 0 ;i < n ; i++){
ll x , y ;
cin >> x >> y ;
ll alldp = 0 ;
for(int j = 0 ;j <= y ;j ++){
alldp = (alldp + dp[j]) %mod ;
}
for(int k = y ; k >=x ; k--){
alldp = (mod + alldp - dp[k]) %mod ;
dp[k] = (dp[k] + alldp) %mod ;
}
}
for(int i = 0 ;i < N ;i++){
ans = (ans + dp[i]) %mod ;
}
cout<< (mod + ans - 1 ) %mod ;
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... |