#include <bits/stdc++.h>
#define N 1050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
pii p[N];
ll n, m, dp[N][N], c[N];
ll solve(int i, int j)
{
if(i > n or j > m) return 0;
if(dp[i][j] != -1) return dp[i][j];
int A = 0, B = solve(i + 1, j), C = solve(i, j + 1);
if(p[i].s <= c[j]) A = solve(i + 1, j + 1) + 1;
return dp[i][j] = max({A, B, C});
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>m;
memset(dp, -1, sizeof dp);
for(int i = 1; i <= n; i++) cin>>p[i].s>>p[i].f;
for(int i = 1; i <= m; i++) cin>>c[i];
sort(c + 1, c + m + 1);
sort(p + 1, p + n + 1);
cout<<solve(1, 1)<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
8960 KB |
Output is correct |
2 |
Correct |
11 ms |
8960 KB |
Output is correct |
3 |
Correct |
9 ms |
8960 KB |
Output is correct |
4 |
Correct |
8 ms |
8960 KB |
Output is correct |
5 |
Correct |
10 ms |
8960 KB |
Output is correct |
6 |
Correct |
9 ms |
8960 KB |
Output is correct |
7 |
Correct |
9 ms |
8960 KB |
Output is correct |
8 |
Correct |
10 ms |
8960 KB |
Output is correct |
9 |
Correct |
10 ms |
8960 KB |
Output is correct |
10 |
Correct |
8 ms |
9004 KB |
Output is correct |
11 |
Correct |
10 ms |
8960 KB |
Output is correct |
12 |
Correct |
8 ms |
8960 KB |
Output is correct |
13 |
Correct |
13 ms |
8960 KB |
Output is correct |
14 |
Correct |
8 ms |
8960 KB |
Output is correct |
15 |
Correct |
9 ms |
8960 KB |
Output is correct |
16 |
Correct |
10 ms |
8960 KB |
Output is correct |
17 |
Correct |
8 ms |
8960 KB |
Output is correct |
18 |
Correct |
11 ms |
8960 KB |
Output is correct |
19 |
Correct |
10 ms |
8932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
8960 KB |
Output is correct |
2 |
Correct |
11 ms |
8960 KB |
Output is correct |
3 |
Correct |
9 ms |
8960 KB |
Output is correct |
4 |
Correct |
8 ms |
8960 KB |
Output is correct |
5 |
Correct |
10 ms |
8960 KB |
Output is correct |
6 |
Correct |
9 ms |
8960 KB |
Output is correct |
7 |
Correct |
9 ms |
8960 KB |
Output is correct |
8 |
Correct |
10 ms |
8960 KB |
Output is correct |
9 |
Correct |
10 ms |
8960 KB |
Output is correct |
10 |
Correct |
8 ms |
9004 KB |
Output is correct |
11 |
Correct |
10 ms |
8960 KB |
Output is correct |
12 |
Correct |
8 ms |
8960 KB |
Output is correct |
13 |
Correct |
13 ms |
8960 KB |
Output is correct |
14 |
Correct |
8 ms |
8960 KB |
Output is correct |
15 |
Correct |
9 ms |
8960 KB |
Output is correct |
16 |
Correct |
10 ms |
8960 KB |
Output is correct |
17 |
Correct |
8 ms |
8960 KB |
Output is correct |
18 |
Correct |
11 ms |
8960 KB |
Output is correct |
19 |
Correct |
10 ms |
8932 KB |
Output is correct |
20 |
Correct |
24 ms |
9108 KB |
Output is correct |
21 |
Correct |
26 ms |
9132 KB |
Output is correct |
22 |
Correct |
24 ms |
9088 KB |
Output is correct |
23 |
Correct |
21 ms |
9088 KB |
Output is correct |
24 |
Correct |
23 ms |
9208 KB |
Output is correct |
25 |
Correct |
22 ms |
9088 KB |
Output is correct |
26 |
Correct |
27 ms |
9088 KB |
Output is correct |
27 |
Correct |
28 ms |
9152 KB |
Output is correct |
28 |
Correct |
22 ms |
9088 KB |
Output is correct |
29 |
Correct |
25 ms |
9088 KB |
Output is correct |
30 |
Correct |
24 ms |
9088 KB |
Output is correct |
31 |
Correct |
21 ms |
9088 KB |
Output is correct |
32 |
Correct |
9 ms |
9088 KB |
Output is correct |
33 |
Correct |
10 ms |
9088 KB |
Output is correct |
34 |
Correct |
14 ms |
9088 KB |
Output is correct |
35 |
Correct |
10 ms |
9088 KB |
Output is correct |
36 |
Correct |
22 ms |
9088 KB |
Output is correct |
37 |
Correct |
27 ms |
9088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
8960 KB |
Output is correct |
2 |
Correct |
11 ms |
8960 KB |
Output is correct |
3 |
Correct |
9 ms |
8960 KB |
Output is correct |
4 |
Correct |
8 ms |
8960 KB |
Output is correct |
5 |
Correct |
10 ms |
8960 KB |
Output is correct |
6 |
Correct |
9 ms |
8960 KB |
Output is correct |
7 |
Correct |
9 ms |
8960 KB |
Output is correct |
8 |
Correct |
10 ms |
8960 KB |
Output is correct |
9 |
Correct |
10 ms |
8960 KB |
Output is correct |
10 |
Correct |
8 ms |
9004 KB |
Output is correct |
11 |
Correct |
10 ms |
8960 KB |
Output is correct |
12 |
Correct |
8 ms |
8960 KB |
Output is correct |
13 |
Correct |
13 ms |
8960 KB |
Output is correct |
14 |
Correct |
8 ms |
8960 KB |
Output is correct |
15 |
Correct |
9 ms |
8960 KB |
Output is correct |
16 |
Correct |
10 ms |
8960 KB |
Output is correct |
17 |
Correct |
8 ms |
8960 KB |
Output is correct |
18 |
Correct |
11 ms |
8960 KB |
Output is correct |
19 |
Correct |
10 ms |
8932 KB |
Output is correct |
20 |
Correct |
24 ms |
9108 KB |
Output is correct |
21 |
Correct |
26 ms |
9132 KB |
Output is correct |
22 |
Correct |
24 ms |
9088 KB |
Output is correct |
23 |
Correct |
21 ms |
9088 KB |
Output is correct |
24 |
Correct |
23 ms |
9208 KB |
Output is correct |
25 |
Correct |
22 ms |
9088 KB |
Output is correct |
26 |
Correct |
27 ms |
9088 KB |
Output is correct |
27 |
Correct |
28 ms |
9152 KB |
Output is correct |
28 |
Correct |
22 ms |
9088 KB |
Output is correct |
29 |
Correct |
25 ms |
9088 KB |
Output is correct |
30 |
Correct |
24 ms |
9088 KB |
Output is correct |
31 |
Correct |
21 ms |
9088 KB |
Output is correct |
32 |
Correct |
9 ms |
9088 KB |
Output is correct |
33 |
Correct |
10 ms |
9088 KB |
Output is correct |
34 |
Correct |
14 ms |
9088 KB |
Output is correct |
35 |
Correct |
10 ms |
9088 KB |
Output is correct |
36 |
Correct |
22 ms |
9088 KB |
Output is correct |
37 |
Correct |
27 ms |
9088 KB |
Output is correct |
38 |
Runtime error |
20 ms |
17792 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
39 |
Halted |
0 ms |
0 KB |
- |