#include <bits/stdc++.h>
using namespace std;
const int mod = (int) 1e9 + 7;
const int N = 502;
int n, a[N], b[N], rel[N];
long long dp[N][N];
long long sol(int i, int hi) {
if (i == n) {
return (hi > 0);
}
long long& ret = dp[i][hi];
if (ret != -1) {
return ret;
}
ret = sol(i + 1, hi);
if (a[i] > hi) {
ret += sol(i + 1, a[i]);
ret %= mod;
}
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
memset(dp, -1, sizeof dp);
cin >> n;
vector<int> se(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
se[i] = a[i];
}
sort(se.begin(), se.end());
map<int, int> mp;
int idd = 1;
for (int i = 0; i < n; i++) {
if (i == 0 || se[i] != se[i - 1]) {
rel[idd] = se[i];
mp[se[i]] = idd++;
}
}
for (int i = 0; i < n; i++) {
a[i] = mp[a[i]];
}
cout << sol(0, 0) << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2252 KB |
Output is correct |
2 |
Correct |
4 ms |
2300 KB |
Output is correct |
3 |
Correct |
3 ms |
2252 KB |
Output is correct |
4 |
Correct |
4 ms |
2252 KB |
Output is correct |
5 |
Correct |
3 ms |
2252 KB |
Output is correct |
6 |
Correct |
4 ms |
2252 KB |
Output is correct |
7 |
Correct |
3 ms |
2252 KB |
Output is correct |
8 |
Correct |
4 ms |
2252 KB |
Output is correct |
9 |
Correct |
4 ms |
2296 KB |
Output is correct |
10 |
Correct |
4 ms |
2296 KB |
Output is correct |
11 |
Correct |
3 ms |
2252 KB |
Output is correct |
12 |
Correct |
3 ms |
2256 KB |
Output is correct |
13 |
Correct |
3 ms |
2252 KB |
Output is correct |
14 |
Correct |
3 ms |
2252 KB |
Output is correct |
15 |
Correct |
3 ms |
2252 KB |
Output is correct |
16 |
Correct |
2 ms |
2252 KB |
Output is correct |
17 |
Correct |
2 ms |
2252 KB |
Output is correct |
18 |
Correct |
2 ms |
2300 KB |
Output is correct |
19 |
Correct |
2 ms |
2252 KB |
Output is correct |
20 |
Correct |
2 ms |
2252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2252 KB |
Output is correct |
2 |
Correct |
4 ms |
2300 KB |
Output is correct |
3 |
Correct |
3 ms |
2252 KB |
Output is correct |
4 |
Correct |
4 ms |
2252 KB |
Output is correct |
5 |
Correct |
3 ms |
2252 KB |
Output is correct |
6 |
Correct |
4 ms |
2252 KB |
Output is correct |
7 |
Correct |
3 ms |
2252 KB |
Output is correct |
8 |
Correct |
4 ms |
2252 KB |
Output is correct |
9 |
Correct |
4 ms |
2296 KB |
Output is correct |
10 |
Correct |
4 ms |
2296 KB |
Output is correct |
11 |
Correct |
3 ms |
2252 KB |
Output is correct |
12 |
Correct |
3 ms |
2256 KB |
Output is correct |
13 |
Correct |
3 ms |
2252 KB |
Output is correct |
14 |
Correct |
3 ms |
2252 KB |
Output is correct |
15 |
Correct |
3 ms |
2252 KB |
Output is correct |
16 |
Correct |
2 ms |
2252 KB |
Output is correct |
17 |
Correct |
2 ms |
2252 KB |
Output is correct |
18 |
Correct |
2 ms |
2300 KB |
Output is correct |
19 |
Correct |
2 ms |
2252 KB |
Output is correct |
20 |
Correct |
2 ms |
2252 KB |
Output is correct |
21 |
Incorrect |
4 ms |
2252 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2252 KB |
Output is correct |
2 |
Correct |
4 ms |
2300 KB |
Output is correct |
3 |
Correct |
3 ms |
2252 KB |
Output is correct |
4 |
Correct |
4 ms |
2252 KB |
Output is correct |
5 |
Correct |
3 ms |
2252 KB |
Output is correct |
6 |
Correct |
4 ms |
2252 KB |
Output is correct |
7 |
Correct |
3 ms |
2252 KB |
Output is correct |
8 |
Correct |
4 ms |
2252 KB |
Output is correct |
9 |
Correct |
4 ms |
2296 KB |
Output is correct |
10 |
Correct |
4 ms |
2296 KB |
Output is correct |
11 |
Correct |
3 ms |
2252 KB |
Output is correct |
12 |
Correct |
3 ms |
2256 KB |
Output is correct |
13 |
Correct |
3 ms |
2252 KB |
Output is correct |
14 |
Correct |
3 ms |
2252 KB |
Output is correct |
15 |
Correct |
3 ms |
2252 KB |
Output is correct |
16 |
Correct |
2 ms |
2252 KB |
Output is correct |
17 |
Correct |
2 ms |
2252 KB |
Output is correct |
18 |
Correct |
2 ms |
2300 KB |
Output is correct |
19 |
Correct |
2 ms |
2252 KB |
Output is correct |
20 |
Correct |
2 ms |
2252 KB |
Output is correct |
21 |
Incorrect |
4 ms |
2252 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |