import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
int[][] arr = new int[n][2];
Integer[] frames = new Integer[m];
for(int i = 0; i < n; i++) {
arr[i][0] = s.nextInt();
arr[i][1] = s.nextInt();
}
for(int i = 0; i < m; i++) frames[i] = s.nextInt();
Arrays.sort(frames, Collections.reverseOrder());
Arrays.sort(arr, (a, b) -> a[1] - b[1]);
int left = 0;
int right = n;
while(left < right) {
int mid = left + (right - left + 1)/2;
boolean works = false;
int[] vals = new int[mid];
for(int i = mid - 1; i >= 0; i--) {
vals[mid - i - 1] = frames[i];
}
int p = 0;
for(int i = 0; i < n; i++) {
if(arr[i][0] <= vals[p]) {
p++;
}
if(p == mid) {
works = true;
break;
}
}
if(works) {
left = mid;
}
else {
right = left - 1;
}
}
System.out.println(left);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
131 ms |
12512 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
131 ms |
12512 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
131 ms |
12512 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |