#include <bits/stdc++.h>
#define MAXN 1010
#define mp make_pair
using namespace std;
typedef pair < int, int > ii;
int n, m, c[MAXN], dp[MAXN][MAXN];
ii phot[MAXN];
inline int func(int u, int ini)
{
if(u >= n or ini >= m) return 0;
if(dp[u][ini] != -1) return dp[u][ini];
int naop = func(u+1, ini);
int pega;
int i = ini, f = m-1, r = -1;
while(i <= f)
{
int meio = (i+f)/2;
if(c[meio] >= phot[u].second)
{
r = meio;
f = meio - 1;
}
else i = meio+1;
}
if(r == -1) pega = 0;
else pega = func(u+1, r+1) + 1;
return dp[u][ini] = max(pega, naop);
}
int main()
{
cin >> n >> m;
memset(dp, -1, sizeof dp);
for(int i = 0 ; i < n ; i++)
{
cin >> phot[i].second >> phot[i].first;
}
for(int i = 0 ; i < m ; i++)
{
cin >> c[i];
}
sort(c, c+m);
sort(phot, phot+n);
int r = func(0, 0);
cout << r << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4352 KB |
Output is correct |
2 |
Correct |
7 ms |
4352 KB |
Output is correct |
3 |
Correct |
6 ms |
4352 KB |
Output is correct |
4 |
Correct |
5 ms |
4352 KB |
Output is correct |
5 |
Correct |
5 ms |
4352 KB |
Output is correct |
6 |
Correct |
7 ms |
4352 KB |
Output is correct |
7 |
Correct |
7 ms |
4348 KB |
Output is correct |
8 |
Correct |
5 ms |
4352 KB |
Output is correct |
9 |
Correct |
5 ms |
4352 KB |
Output is correct |
10 |
Correct |
6 ms |
4352 KB |
Output is correct |
11 |
Correct |
6 ms |
4352 KB |
Output is correct |
12 |
Correct |
7 ms |
4352 KB |
Output is correct |
13 |
Correct |
6 ms |
4352 KB |
Output is correct |
14 |
Correct |
7 ms |
4352 KB |
Output is correct |
15 |
Correct |
5 ms |
4352 KB |
Output is correct |
16 |
Correct |
7 ms |
4352 KB |
Output is correct |
17 |
Correct |
8 ms |
4352 KB |
Output is correct |
18 |
Correct |
6 ms |
4352 KB |
Output is correct |
19 |
Correct |
6 ms |
4352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4352 KB |
Output is correct |
2 |
Correct |
7 ms |
4352 KB |
Output is correct |
3 |
Correct |
6 ms |
4352 KB |
Output is correct |
4 |
Correct |
5 ms |
4352 KB |
Output is correct |
5 |
Correct |
5 ms |
4352 KB |
Output is correct |
6 |
Correct |
7 ms |
4352 KB |
Output is correct |
7 |
Correct |
7 ms |
4348 KB |
Output is correct |
8 |
Correct |
5 ms |
4352 KB |
Output is correct |
9 |
Correct |
5 ms |
4352 KB |
Output is correct |
10 |
Correct |
6 ms |
4352 KB |
Output is correct |
11 |
Correct |
6 ms |
4352 KB |
Output is correct |
12 |
Correct |
7 ms |
4352 KB |
Output is correct |
13 |
Correct |
6 ms |
4352 KB |
Output is correct |
14 |
Correct |
7 ms |
4352 KB |
Output is correct |
15 |
Correct |
5 ms |
4352 KB |
Output is correct |
16 |
Correct |
7 ms |
4352 KB |
Output is correct |
17 |
Correct |
8 ms |
4352 KB |
Output is correct |
18 |
Correct |
6 ms |
4352 KB |
Output is correct |
19 |
Correct |
6 ms |
4352 KB |
Output is correct |
20 |
Correct |
46 ms |
4472 KB |
Output is correct |
21 |
Correct |
28 ms |
4472 KB |
Output is correct |
22 |
Correct |
8 ms |
4352 KB |
Output is correct |
23 |
Correct |
31 ms |
4352 KB |
Output is correct |
24 |
Correct |
24 ms |
4352 KB |
Output is correct |
25 |
Correct |
36 ms |
4352 KB |
Output is correct |
26 |
Correct |
34 ms |
4404 KB |
Output is correct |
27 |
Correct |
6 ms |
4352 KB |
Output is correct |
28 |
Correct |
6 ms |
4352 KB |
Output is correct |
29 |
Correct |
20 ms |
4352 KB |
Output is correct |
30 |
Correct |
34 ms |
4380 KB |
Output is correct |
31 |
Correct |
45 ms |
4352 KB |
Output is correct |
32 |
Correct |
8 ms |
4352 KB |
Output is correct |
33 |
Correct |
5 ms |
4352 KB |
Output is correct |
34 |
Correct |
19 ms |
4352 KB |
Output is correct |
35 |
Correct |
6 ms |
4352 KB |
Output is correct |
36 |
Correct |
58 ms |
4404 KB |
Output is correct |
37 |
Correct |
66 ms |
4224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
4352 KB |
Output is correct |
2 |
Correct |
7 ms |
4352 KB |
Output is correct |
3 |
Correct |
6 ms |
4352 KB |
Output is correct |
4 |
Correct |
5 ms |
4352 KB |
Output is correct |
5 |
Correct |
5 ms |
4352 KB |
Output is correct |
6 |
Correct |
7 ms |
4352 KB |
Output is correct |
7 |
Correct |
7 ms |
4348 KB |
Output is correct |
8 |
Correct |
5 ms |
4352 KB |
Output is correct |
9 |
Correct |
5 ms |
4352 KB |
Output is correct |
10 |
Correct |
6 ms |
4352 KB |
Output is correct |
11 |
Correct |
6 ms |
4352 KB |
Output is correct |
12 |
Correct |
7 ms |
4352 KB |
Output is correct |
13 |
Correct |
6 ms |
4352 KB |
Output is correct |
14 |
Correct |
7 ms |
4352 KB |
Output is correct |
15 |
Correct |
5 ms |
4352 KB |
Output is correct |
16 |
Correct |
7 ms |
4352 KB |
Output is correct |
17 |
Correct |
8 ms |
4352 KB |
Output is correct |
18 |
Correct |
6 ms |
4352 KB |
Output is correct |
19 |
Correct |
6 ms |
4352 KB |
Output is correct |
20 |
Correct |
46 ms |
4472 KB |
Output is correct |
21 |
Correct |
28 ms |
4472 KB |
Output is correct |
22 |
Correct |
8 ms |
4352 KB |
Output is correct |
23 |
Correct |
31 ms |
4352 KB |
Output is correct |
24 |
Correct |
24 ms |
4352 KB |
Output is correct |
25 |
Correct |
36 ms |
4352 KB |
Output is correct |
26 |
Correct |
34 ms |
4404 KB |
Output is correct |
27 |
Correct |
6 ms |
4352 KB |
Output is correct |
28 |
Correct |
6 ms |
4352 KB |
Output is correct |
29 |
Correct |
20 ms |
4352 KB |
Output is correct |
30 |
Correct |
34 ms |
4380 KB |
Output is correct |
31 |
Correct |
45 ms |
4352 KB |
Output is correct |
32 |
Correct |
8 ms |
4352 KB |
Output is correct |
33 |
Correct |
5 ms |
4352 KB |
Output is correct |
34 |
Correct |
19 ms |
4352 KB |
Output is correct |
35 |
Correct |
6 ms |
4352 KB |
Output is correct |
36 |
Correct |
58 ms |
4404 KB |
Output is correct |
37 |
Correct |
66 ms |
4224 KB |
Output is correct |
38 |
Runtime error |
106 ms |
8464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
39 |
Halted |
0 ms |
0 KB |
- |