from heapq import *
n,m = map(int, input().split())
pictures = []
frames = []
for i in range(n):
pictures.append(list(map(int, input().split())))
for i in range(m):
frames.append(int(input()))
pictures.sort(key=lambda x:(x[1], x[0]))
frames.sort()
cur = n-1
cur2 = m-1
ans = 0
while 0<=cur and 0<=cur2:
if frames[cur2] >= pictures[cur][0]:
ans += 1
cur2 -= 1
cur -= 1
else:
cur -= 1
print(ans)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
18220 KB |
Output is correct |
2 |
Correct |
42 ms |
18248 KB |
Output is correct |
3 |
Correct |
38 ms |
18300 KB |
Output is correct |
4 |
Correct |
55 ms |
18316 KB |
Output is correct |
5 |
Correct |
55 ms |
18220 KB |
Output is correct |
6 |
Correct |
39 ms |
18220 KB |
Output is correct |
7 |
Correct |
40 ms |
18220 KB |
Output is correct |
8 |
Correct |
39 ms |
18236 KB |
Output is correct |
9 |
Correct |
37 ms |
18304 KB |
Output is correct |
10 |
Correct |
42 ms |
18236 KB |
Output is correct |
11 |
Correct |
44 ms |
18212 KB |
Output is correct |
12 |
Correct |
49 ms |
18256 KB |
Output is correct |
13 |
Correct |
40 ms |
18220 KB |
Output is correct |
14 |
Correct |
38 ms |
18220 KB |
Output is correct |
15 |
Correct |
39 ms |
18144 KB |
Output is correct |
16 |
Correct |
38 ms |
18164 KB |
Output is correct |
17 |
Correct |
36 ms |
18236 KB |
Output is correct |
18 |
Correct |
40 ms |
18284 KB |
Output is correct |
19 |
Correct |
37 ms |
18224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
18220 KB |
Output is correct |
2 |
Correct |
42 ms |
18248 KB |
Output is correct |
3 |
Correct |
38 ms |
18300 KB |
Output is correct |
4 |
Correct |
55 ms |
18316 KB |
Output is correct |
5 |
Correct |
55 ms |
18220 KB |
Output is correct |
6 |
Correct |
39 ms |
18220 KB |
Output is correct |
7 |
Correct |
40 ms |
18220 KB |
Output is correct |
8 |
Correct |
39 ms |
18236 KB |
Output is correct |
9 |
Correct |
37 ms |
18304 KB |
Output is correct |
10 |
Correct |
42 ms |
18236 KB |
Output is correct |
11 |
Correct |
44 ms |
18212 KB |
Output is correct |
12 |
Correct |
49 ms |
18256 KB |
Output is correct |
13 |
Correct |
40 ms |
18220 KB |
Output is correct |
14 |
Correct |
38 ms |
18220 KB |
Output is correct |
15 |
Correct |
39 ms |
18144 KB |
Output is correct |
16 |
Correct |
38 ms |
18164 KB |
Output is correct |
17 |
Correct |
36 ms |
18236 KB |
Output is correct |
18 |
Correct |
40 ms |
18284 KB |
Output is correct |
19 |
Correct |
37 ms |
18224 KB |
Output is correct |
20 |
Correct |
109 ms |
21488 KB |
Output is correct |
21 |
Correct |
115 ms |
21352 KB |
Output is correct |
22 |
Correct |
103 ms |
21400 KB |
Output is correct |
23 |
Correct |
97 ms |
21208 KB |
Output is correct |
24 |
Correct |
113 ms |
21200 KB |
Output is correct |
25 |
Correct |
108 ms |
21200 KB |
Output is correct |
26 |
Correct |
112 ms |
21336 KB |
Output is correct |
27 |
Correct |
94 ms |
21284 KB |
Output is correct |
28 |
Correct |
92 ms |
21248 KB |
Output is correct |
29 |
Correct |
110 ms |
21308 KB |
Output is correct |
30 |
Correct |
157 ms |
21248 KB |
Output is correct |
31 |
Correct |
106 ms |
21292 KB |
Output is correct |
32 |
Correct |
69 ms |
19368 KB |
Output is correct |
33 |
Correct |
59 ms |
18988 KB |
Output is correct |
34 |
Correct |
84 ms |
20068 KB |
Output is correct |
35 |
Correct |
70 ms |
19192 KB |
Output is correct |
36 |
Correct |
103 ms |
21328 KB |
Output is correct |
37 |
Correct |
96 ms |
21280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
18220 KB |
Output is correct |
2 |
Correct |
42 ms |
18248 KB |
Output is correct |
3 |
Correct |
38 ms |
18300 KB |
Output is correct |
4 |
Correct |
55 ms |
18316 KB |
Output is correct |
5 |
Correct |
55 ms |
18220 KB |
Output is correct |
6 |
Correct |
39 ms |
18220 KB |
Output is correct |
7 |
Correct |
40 ms |
18220 KB |
Output is correct |
8 |
Correct |
39 ms |
18236 KB |
Output is correct |
9 |
Correct |
37 ms |
18304 KB |
Output is correct |
10 |
Correct |
42 ms |
18236 KB |
Output is correct |
11 |
Correct |
44 ms |
18212 KB |
Output is correct |
12 |
Correct |
49 ms |
18256 KB |
Output is correct |
13 |
Correct |
40 ms |
18220 KB |
Output is correct |
14 |
Correct |
38 ms |
18220 KB |
Output is correct |
15 |
Correct |
39 ms |
18144 KB |
Output is correct |
16 |
Correct |
38 ms |
18164 KB |
Output is correct |
17 |
Correct |
36 ms |
18236 KB |
Output is correct |
18 |
Correct |
40 ms |
18284 KB |
Output is correct |
19 |
Correct |
37 ms |
18224 KB |
Output is correct |
20 |
Correct |
109 ms |
21488 KB |
Output is correct |
21 |
Correct |
115 ms |
21352 KB |
Output is correct |
22 |
Correct |
103 ms |
21400 KB |
Output is correct |
23 |
Correct |
97 ms |
21208 KB |
Output is correct |
24 |
Correct |
113 ms |
21200 KB |
Output is correct |
25 |
Correct |
108 ms |
21200 KB |
Output is correct |
26 |
Correct |
112 ms |
21336 KB |
Output is correct |
27 |
Correct |
94 ms |
21284 KB |
Output is correct |
28 |
Correct |
92 ms |
21248 KB |
Output is correct |
29 |
Correct |
110 ms |
21308 KB |
Output is correct |
30 |
Correct |
157 ms |
21248 KB |
Output is correct |
31 |
Correct |
106 ms |
21292 KB |
Output is correct |
32 |
Correct |
69 ms |
19368 KB |
Output is correct |
33 |
Correct |
59 ms |
18988 KB |
Output is correct |
34 |
Correct |
84 ms |
20068 KB |
Output is correct |
35 |
Correct |
70 ms |
19192 KB |
Output is correct |
36 |
Correct |
103 ms |
21328 KB |
Output is correct |
37 |
Correct |
96 ms |
21280 KB |
Output is correct |
38 |
Correct |
840 ms |
44844 KB |
Output is correct |
39 |
Correct |
765 ms |
44800 KB |
Output is correct |
40 |
Correct |
731 ms |
45036 KB |
Output is correct |
41 |
Correct |
812 ms |
44812 KB |
Output is correct |
42 |
Correct |
938 ms |
44860 KB |
Output is correct |
43 |
Correct |
908 ms |
45348 KB |
Output is correct |
44 |
Correct |
838 ms |
44404 KB |
Output is correct |
45 |
Correct |
832 ms |
45368 KB |
Output is correct |
46 |
Correct |
901 ms |
44808 KB |
Output is correct |
47 |
Correct |
776 ms |
44924 KB |
Output is correct |
48 |
Correct |
880 ms |
43356 KB |
Output is correct |
49 |
Correct |
707 ms |
38916 KB |
Output is correct |
50 |
Correct |
811 ms |
39620 KB |
Output is correct |
51 |
Correct |
911 ms |
44792 KB |
Output is correct |
52 |
Correct |
877 ms |
44804 KB |
Output is correct |
53 |
Correct |
991 ms |
45248 KB |
Output is correct |
54 |
Correct |
899 ms |
45368 KB |
Output is correct |
55 |
Correct |
996 ms |
44804 KB |
Output is correct |
56 |
Correct |
671 ms |
39476 KB |
Output is correct |
57 |
Correct |
287 ms |
27556 KB |
Output is correct |
58 |
Correct |
642 ms |
39444 KB |
Output is correct |
59 |
Correct |
722 ms |
39668 KB |
Output is correct |
60 |
Correct |
306 ms |
28180 KB |
Output is correct |
61 |
Correct |
467 ms |
33412 KB |
Output is correct |
62 |
Correct |
996 ms |
44724 KB |
Output is correct |
63 |
Correct |
923 ms |
44720 KB |
Output is correct |
64 |
Correct |
928 ms |
44972 KB |
Output is correct |
65 |
Correct |
913 ms |
44768 KB |
Output is correct |
66 |
Correct |
910 ms |
44796 KB |
Output is correct |
67 |
Correct |
824 ms |
44840 KB |
Output is correct |
68 |
Correct |
878 ms |
44868 KB |
Output is correct |
69 |
Correct |
857 ms |
44512 KB |
Output is correct |
70 |
Correct |
856 ms |
45352 KB |
Output is correct |
71 |
Correct |
880 ms |
45276 KB |
Output is correct |
72 |
Correct |
850 ms |
44888 KB |
Output is correct |
73 |
Correct |
875 ms |
45356 KB |
Output is correct |