#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,mmx,bmi,bmi2,popcnt,lzcnt,sse4.2,abm")
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3;
int n, m, dp[MAXN+5][MAXN+5], f[MAXN+5];
pair<int, int> p[MAXN];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m;
for(int i=0; i<n; i++) cin>>p[i].second>>p[i].first;
for(int i=0; i<m; i++) cin>>f[i];
sort(f, f+m, greater<int>());
sort(p, p+n, greater<pair<int,int>>());
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
if(p[i-1].second <= f[j-1]) dp[i][j] = max(dp[i-1][j-1]+1, max(dp[i-1][j], dp[i][j-1]));
else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
}
}
cout << dp[n][m] << '\n';
/* for(int i=0; i<=n; i++) { */
/* for(int j=0; j<=m; j++) cout<<dp[i][j] << ' '; */
/* cout<<endl; */
/* } */
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
5 ms |
4188 KB |
Output is correct |
21 |
Correct |
5 ms |
4208 KB |
Output is correct |
22 |
Correct |
4 ms |
4188 KB |
Output is correct |
23 |
Correct |
5 ms |
4444 KB |
Output is correct |
24 |
Correct |
6 ms |
4188 KB |
Output is correct |
25 |
Correct |
6 ms |
4188 KB |
Output is correct |
26 |
Correct |
6 ms |
4188 KB |
Output is correct |
27 |
Correct |
4 ms |
4184 KB |
Output is correct |
28 |
Correct |
4 ms |
4220 KB |
Output is correct |
29 |
Correct |
7 ms |
4224 KB |
Output is correct |
30 |
Correct |
5 ms |
4188 KB |
Output is correct |
31 |
Correct |
5 ms |
4188 KB |
Output is correct |
32 |
Correct |
2 ms |
4188 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
4 ms |
4188 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
5 ms |
4188 KB |
Output is correct |
37 |
Correct |
5 ms |
4224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
5 ms |
4188 KB |
Output is correct |
21 |
Correct |
5 ms |
4208 KB |
Output is correct |
22 |
Correct |
4 ms |
4188 KB |
Output is correct |
23 |
Correct |
5 ms |
4444 KB |
Output is correct |
24 |
Correct |
6 ms |
4188 KB |
Output is correct |
25 |
Correct |
6 ms |
4188 KB |
Output is correct |
26 |
Correct |
6 ms |
4188 KB |
Output is correct |
27 |
Correct |
4 ms |
4184 KB |
Output is correct |
28 |
Correct |
4 ms |
4220 KB |
Output is correct |
29 |
Correct |
7 ms |
4224 KB |
Output is correct |
30 |
Correct |
5 ms |
4188 KB |
Output is correct |
31 |
Correct |
5 ms |
4188 KB |
Output is correct |
32 |
Correct |
2 ms |
4188 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
4 ms |
4188 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
5 ms |
4188 KB |
Output is correct |
37 |
Correct |
5 ms |
4224 KB |
Output is correct |
38 |
Runtime error |
276 ms |
8624 KB |
Execution killed with signal 11 |
39 |
Halted |
0 ms |
0 KB |
- |