#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int md = (int)1e9 + 7;
const int N = (int)1e5 + 1;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
vector<vector<int>> dp(n, vector<int>(N));
for (int i = 0; i < n; i++) {
for (int j = a[i]; j <= b[i]; j++) {
dp[i][j] = 1;
for (int k = 0; k < i; k++) {
for (int l = a[k]; l <= min(b[k], j - 1); l++) {
dp[i][j] = (dp[i][j] + dp[k][l]) % md;
}
}
}
}
int sm = 0;
for (auto i : dp) {
for (auto j : i) sm = (sm + j) % md;
}
cout << sm;
}
/*sub1
vector<int> dp(n);
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
if (a[j] < a[i]) dp[i] = (dp[i] + dp[j]) % md;
}
}
int sm = 0;
for (auto i : dp) sm = (sm + i) % md;
cout << sm;
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
224 ms |
398788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
224 ms |
398788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
47 ms |
80064 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
224 ms |
398788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |