Submission #725963

# Submission time Handle Problem Language Result Execution time Memory
725963 2023-04-18T09:23:34 Z browntoad Exhibition (JOI19_ho_t2) Java 11
50 / 100
1000 ms 23984 KB
import java.util.*;
import java.io.*;
 
class FastIO extends PrintWriter {
	private InputStream stream;
	private byte[] buf = new byte[1 << 16];
	private int curChar;
	private int numChars;
 
	// standard input
	public FastIO() { this(System.in, System.out); }
 
	public FastIO(InputStream i, OutputStream o) {
		super(o);
		stream = i;
	}
 
	// file input
	public FastIO(String i, String o) throws IOException {
		super(new FileWriter(o));
		stream = new FileInputStream(i);
	}
 
	// throws InputMismatchException() if previously detected end of file
	private int nextByte() {
		if (numChars == -1) { throw new InputMismatchException(); }
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) { throw new InputMismatchException(); }
			if (numChars == -1) {
				return -1;  // end of file
			}
		}
		return buf[curChar++];
	}
 
	// to read in entire lines, replace c <= ' '
	// with a function that checks whether c is a line break
	public String next() {
		int c;
		do { c = nextByte(); } while (c <= ' ');
 
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = nextByte();
		} while (c > ' ');
		return res.toString();
	}
 
	public int nextInt() {  // nextLong() would be implemented similarly
		int c;
		do { c = nextByte(); } while (c <= ' ');
 
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = nextByte();
		}
 
		int res = 0;
		do {
			if (c < '0' || c > '9') { throw new InputMismatchException(); }
			res = 10 * res + c - '0';
			c = nextByte();
		} while (c > ' ');
		return res * sgn;
	}
 
	public double nextDouble() { return Double.parseDouble(next()); }
}
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){
        FastIO io = new FastIO();
        int N = io.nextInt();
        int M = io.nextInt();
 
        Pair[] pictures = new Pair[N];
        ArrayList<Integer> frame = new ArrayList<Integer>();
 
        for (int i=0; i<N; i++) {
            pictures[i] = new Pair(io.nextInt(), io.nextInt());
        }
 
        for (int i=0; i<M; i++) {
            frame.add(io.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 66 ms 8724 KB Output is correct
2 Correct 63 ms 8368 KB Output is correct
3 Correct 69 ms 8476 KB Output is correct
4 Correct 62 ms 8480 KB Output is correct
5 Correct 71 ms 8316 KB Output is correct
6 Correct 73 ms 8464 KB Output is correct
7 Correct 68 ms 8372 KB Output is correct
8 Correct 63 ms 8284 KB Output is correct
9 Correct 65 ms 8476 KB Output is correct
10 Correct 64 ms 8392 KB Output is correct
11 Correct 71 ms 8296 KB Output is correct
12 Correct 75 ms 8352 KB Output is correct
13 Correct 64 ms 8300 KB Output is correct
14 Correct 93 ms 8324 KB Output is correct
15 Correct 63 ms 8660 KB Output is correct
16 Correct 65 ms 8236 KB Output is correct
17 Correct 83 ms 8196 KB Output is correct
18 Correct 69 ms 8384 KB Output is correct
19 Correct 63 ms 8348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 8724 KB Output is correct
2 Correct 63 ms 8368 KB Output is correct
3 Correct 69 ms 8476 KB Output is correct
4 Correct 62 ms 8480 KB Output is correct
5 Correct 71 ms 8316 KB Output is correct
6 Correct 73 ms 8464 KB Output is correct
7 Correct 68 ms 8372 KB Output is correct
8 Correct 63 ms 8284 KB Output is correct
9 Correct 65 ms 8476 KB Output is correct
10 Correct 64 ms 8392 KB Output is correct
11 Correct 71 ms 8296 KB Output is correct
12 Correct 75 ms 8352 KB Output is correct
13 Correct 64 ms 8300 KB Output is correct
14 Correct 93 ms 8324 KB Output is correct
15 Correct 63 ms 8660 KB Output is correct
16 Correct 65 ms 8236 KB Output is correct
17 Correct 83 ms 8196 KB Output is correct
18 Correct 69 ms 8384 KB Output is correct
19 Correct 63 ms 8348 KB Output is correct
20 Correct 108 ms 8608 KB Output is correct
21 Correct 75 ms 8432 KB Output is correct
22 Correct 79 ms 8644 KB Output is correct
23 Correct 82 ms 8600 KB Output is correct
24 Correct 80 ms 8684 KB Output is correct
25 Correct 99 ms 8560 KB Output is correct
26 Correct 86 ms 8832 KB Output is correct
27 Correct 76 ms 8916 KB Output is correct
28 Correct 75 ms 8816 KB Output is correct
29 Correct 84 ms 8500 KB Output is correct
30 Correct 76 ms 8624 KB Output is correct
31 Correct 77 ms 8672 KB Output is correct
32 Correct 83 ms 8636 KB Output is correct
33 Correct 69 ms 8420 KB Output is correct
34 Correct 94 ms 8388 KB Output is correct
35 Correct 72 ms 8336 KB Output is correct
36 Correct 81 ms 8660 KB Output is correct
37 Correct 79 ms 8620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 8724 KB Output is correct
2 Correct 63 ms 8368 KB Output is correct
3 Correct 69 ms 8476 KB Output is correct
4 Correct 62 ms 8480 KB Output is correct
5 Correct 71 ms 8316 KB Output is correct
6 Correct 73 ms 8464 KB Output is correct
7 Correct 68 ms 8372 KB Output is correct
8 Correct 63 ms 8284 KB Output is correct
9 Correct 65 ms 8476 KB Output is correct
10 Correct 64 ms 8392 KB Output is correct
11 Correct 71 ms 8296 KB Output is correct
12 Correct 75 ms 8352 KB Output is correct
13 Correct 64 ms 8300 KB Output is correct
14 Correct 93 ms 8324 KB Output is correct
15 Correct 63 ms 8660 KB Output is correct
16 Correct 65 ms 8236 KB Output is correct
17 Correct 83 ms 8196 KB Output is correct
18 Correct 69 ms 8384 KB Output is correct
19 Correct 63 ms 8348 KB Output is correct
20 Correct 108 ms 8608 KB Output is correct
21 Correct 75 ms 8432 KB Output is correct
22 Correct 79 ms 8644 KB Output is correct
23 Correct 82 ms 8600 KB Output is correct
24 Correct 80 ms 8684 KB Output is correct
25 Correct 99 ms 8560 KB Output is correct
26 Correct 86 ms 8832 KB Output is correct
27 Correct 76 ms 8916 KB Output is correct
28 Correct 75 ms 8816 KB Output is correct
29 Correct 84 ms 8500 KB Output is correct
30 Correct 76 ms 8624 KB Output is correct
31 Correct 77 ms 8672 KB Output is correct
32 Correct 83 ms 8636 KB Output is correct
33 Correct 69 ms 8420 KB Output is correct
34 Correct 94 ms 8388 KB Output is correct
35 Correct 72 ms 8336 KB Output is correct
36 Correct 81 ms 8660 KB Output is correct
37 Correct 79 ms 8620 KB Output is correct
38 Execution timed out 1042 ms 23984 KB Time limit exceeded
39 Halted 0 ms 0 KB -