답안 #730549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
730549 2023-04-26T05:33:40 Z rahulverma Exhibition (JOI19_ho_t2) Java 11
0 / 100
70 ms 9012 KB
import java.io.*;
import java.util.*;

public class joi2019_ho_t2 {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int[][] arr = new int[n][2];
		Integer[] frames = new Integer[m];
		for(int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			arr[i][0] = Integer.parseInt(st.nextToken());
			arr[i][1] = Integer.parseInt(st.nextToken());
		}
		for(int i = 0; i < m; i++) frames[i] = Integer.parseInt(br.readLine());
		Arrays.sort(frames, Collections.reverseOrder());
		Arrays.sort(arr, (a, b) -> a[1] - b[1]);
		int left = 0;
		int right = m;
		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 = mid - 1;
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(left);
		pw.close();
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 8988 KB Output is correct
2 Correct 70 ms 8928 KB Output is correct
3 Incorrect 66 ms 9012 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 8988 KB Output is correct
2 Correct 70 ms 8928 KB Output is correct
3 Incorrect 66 ms 9012 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 8988 KB Output is correct
2 Correct 70 ms 8928 KB Output is correct
3 Incorrect 66 ms 9012 KB Output isn't correct
4 Halted 0 ms 0 KB -