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 N = 5e2 + 5;
#define ll long long
ll a[N], b[N];
int dp[N], mod = 1e9 + 7, n;
map <ll, int> m;
int main () {
// freopen ("input.txt", "r", stdin);
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
assert (n <= 50);
for (int i = 1; i <= n; ++i) {
cin >> a[i] >> b[i];
}
for (int i = 1; i <= n; ++i) {
for (int j = a[i]; j <= b[i]; ++j) {
m[j] = 1;
}
}
int san = 0;
for (auto i : m) {
m[i.first] = ++san;
}
for (int i = 1; i <= n; ++i) {
a[i] = m[a[i]]; b[i] = m[b[i]];
}
dp[0] = 1;
for (int i = 1; i <= n; ++i) {
// if (i == 2) {
// return cout << dp[2], 0;
// }
for (int j = b[i]; j >= a[i]; j--) {
int sum = 0;
for (int l = 0; l < j; ++l) {
sum += dp[l];
sum %= mod;
}
dp[j] += sum;
dp[j] %= mod;
}
}
int jog = 0;
for (int i = 1; i <= san; ++i) {
jog += dp[i];
// cout << i << " " << dp[i] << "\n";
}
cout << jog;
}
# | 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... |