import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
class Pair {
int x;
int y;
// Constructor
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
class ArrayOfPairsSorter {
static void sort(Pair[] arr) {
Comparator<Pair> comparator = new Comparator<>() {
@Override
public int compare(Pair p1, Pair p2) {
if (p1.y == p2.y) return p1.x - p2.x;
return p1.y - p2.y;
}
};
Arrays.sort(arr, comparator);
}
}
class joi2019_ho_t2 {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int M = scanner.nextInt();
Pair[] pictures = new Pair[N];
ArrayList<Integer> frame = new ArrayList<Integer>();
for (int i=0; i<N; i++) {
pictures[i] = new Pair(scanner.nextInt(), scanner.nextInt());
}
for (int i=0; i<M; i++) {
frame.add(scanner.nextInt());
}
ArrayOfPairsSorter.sort(pictures);
Collections.sort(frame);
int paintingCounter = N;
int frameCounter = M-1;
for (int i=N-1; i>=0; i--) {
if (frameCounter >= 0) {
if (pictures[i].x <= frame.get(frameCounter)) {
frameCounter -= 1;
}
}
}
System.out.println(M - 1 - frameCounter);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
10356 KB |
Output is correct |
2 |
Correct |
103 ms |
10120 KB |
Output is correct |
3 |
Correct |
98 ms |
10180 KB |
Output is correct |
4 |
Correct |
100 ms |
10176 KB |
Output is correct |
5 |
Correct |
102 ms |
10060 KB |
Output is correct |
6 |
Correct |
105 ms |
10068 KB |
Output is correct |
7 |
Correct |
110 ms |
10152 KB |
Output is correct |
8 |
Correct |
105 ms |
10104 KB |
Output is correct |
9 |
Correct |
109 ms |
10296 KB |
Output is correct |
10 |
Correct |
118 ms |
10080 KB |
Output is correct |
11 |
Correct |
112 ms |
10012 KB |
Output is correct |
12 |
Correct |
127 ms |
10220 KB |
Output is correct |
13 |
Correct |
103 ms |
10148 KB |
Output is correct |
14 |
Correct |
96 ms |
10004 KB |
Output is correct |
15 |
Correct |
98 ms |
10364 KB |
Output is correct |
16 |
Correct |
102 ms |
10076 KB |
Output is correct |
17 |
Correct |
109 ms |
10108 KB |
Output is correct |
18 |
Correct |
100 ms |
10260 KB |
Output is correct |
19 |
Correct |
102 ms |
10164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
10356 KB |
Output is correct |
2 |
Correct |
103 ms |
10120 KB |
Output is correct |
3 |
Correct |
98 ms |
10180 KB |
Output is correct |
4 |
Correct |
100 ms |
10176 KB |
Output is correct |
5 |
Correct |
102 ms |
10060 KB |
Output is correct |
6 |
Correct |
105 ms |
10068 KB |
Output is correct |
7 |
Correct |
110 ms |
10152 KB |
Output is correct |
8 |
Correct |
105 ms |
10104 KB |
Output is correct |
9 |
Correct |
109 ms |
10296 KB |
Output is correct |
10 |
Correct |
118 ms |
10080 KB |
Output is correct |
11 |
Correct |
112 ms |
10012 KB |
Output is correct |
12 |
Correct |
127 ms |
10220 KB |
Output is correct |
13 |
Correct |
103 ms |
10148 KB |
Output is correct |
14 |
Correct |
96 ms |
10004 KB |
Output is correct |
15 |
Correct |
98 ms |
10364 KB |
Output is correct |
16 |
Correct |
102 ms |
10076 KB |
Output is correct |
17 |
Correct |
109 ms |
10108 KB |
Output is correct |
18 |
Correct |
100 ms |
10260 KB |
Output is correct |
19 |
Correct |
102 ms |
10164 KB |
Output is correct |
20 |
Correct |
303 ms |
15268 KB |
Output is correct |
21 |
Correct |
338 ms |
14912 KB |
Output is correct |
22 |
Correct |
307 ms |
14780 KB |
Output is correct |
23 |
Correct |
316 ms |
14964 KB |
Output is correct |
24 |
Correct |
317 ms |
15044 KB |
Output is correct |
25 |
Correct |
325 ms |
15172 KB |
Output is correct |
26 |
Correct |
293 ms |
14952 KB |
Output is correct |
27 |
Correct |
317 ms |
14900 KB |
Output is correct |
28 |
Correct |
315 ms |
15144 KB |
Output is correct |
29 |
Correct |
299 ms |
14984 KB |
Output is correct |
30 |
Correct |
323 ms |
15080 KB |
Output is correct |
31 |
Correct |
312 ms |
14972 KB |
Output is correct |
32 |
Correct |
321 ms |
14984 KB |
Output is correct |
33 |
Correct |
217 ms |
12508 KB |
Output is correct |
34 |
Correct |
293 ms |
15024 KB |
Output is correct |
35 |
Correct |
258 ms |
14092 KB |
Output is correct |
36 |
Correct |
348 ms |
14900 KB |
Output is correct |
37 |
Correct |
332 ms |
14904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
10356 KB |
Output is correct |
2 |
Correct |
103 ms |
10120 KB |
Output is correct |
3 |
Correct |
98 ms |
10180 KB |
Output is correct |
4 |
Correct |
100 ms |
10176 KB |
Output is correct |
5 |
Correct |
102 ms |
10060 KB |
Output is correct |
6 |
Correct |
105 ms |
10068 KB |
Output is correct |
7 |
Correct |
110 ms |
10152 KB |
Output is correct |
8 |
Correct |
105 ms |
10104 KB |
Output is correct |
9 |
Correct |
109 ms |
10296 KB |
Output is correct |
10 |
Correct |
118 ms |
10080 KB |
Output is correct |
11 |
Correct |
112 ms |
10012 KB |
Output is correct |
12 |
Correct |
127 ms |
10220 KB |
Output is correct |
13 |
Correct |
103 ms |
10148 KB |
Output is correct |
14 |
Correct |
96 ms |
10004 KB |
Output is correct |
15 |
Correct |
98 ms |
10364 KB |
Output is correct |
16 |
Correct |
102 ms |
10076 KB |
Output is correct |
17 |
Correct |
109 ms |
10108 KB |
Output is correct |
18 |
Correct |
100 ms |
10260 KB |
Output is correct |
19 |
Correct |
102 ms |
10164 KB |
Output is correct |
20 |
Correct |
303 ms |
15268 KB |
Output is correct |
21 |
Correct |
338 ms |
14912 KB |
Output is correct |
22 |
Correct |
307 ms |
14780 KB |
Output is correct |
23 |
Correct |
316 ms |
14964 KB |
Output is correct |
24 |
Correct |
317 ms |
15044 KB |
Output is correct |
25 |
Correct |
325 ms |
15172 KB |
Output is correct |
26 |
Correct |
293 ms |
14952 KB |
Output is correct |
27 |
Correct |
317 ms |
14900 KB |
Output is correct |
28 |
Correct |
315 ms |
15144 KB |
Output is correct |
29 |
Correct |
299 ms |
14984 KB |
Output is correct |
30 |
Correct |
323 ms |
15080 KB |
Output is correct |
31 |
Correct |
312 ms |
14972 KB |
Output is correct |
32 |
Correct |
321 ms |
14984 KB |
Output is correct |
33 |
Correct |
217 ms |
12508 KB |
Output is correct |
34 |
Correct |
293 ms |
15024 KB |
Output is correct |
35 |
Correct |
258 ms |
14092 KB |
Output is correct |
36 |
Correct |
348 ms |
14900 KB |
Output is correct |
37 |
Correct |
332 ms |
14904 KB |
Output is correct |
38 |
Execution timed out |
1087 ms |
26976 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |