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;
#define int long long
#define fr first
#define sc second
const int mod = 1e9+7;
int n;
int32_t main() {
cin >> n;
map<int,int> dp;
dp[0] = 1;
for(int i = 1; i <= n; i++) {
int a,b; cin >> a >> b;
int sum = 0;
for(auto X : dp) {
if(X.fr >= a) continue;
sum+= X.sc;
sum%= mod;
}
for(int j = a; j <= b; j++) {
sum+= dp[j];
sum%= mod;
dp[j] = sum;
}
}
int ans = 0;
for(auto x : dp) {
if(x.fr != 0) {
ans+= x.sc;
ans%= mod;
}
}
cout << ans << endl;
}
# | 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... |