For this Question: Given N integers, your task is to add these elements to the PriorityQueue. Also, given M integers, the task is to check if element is present in PriorityQueue. If present, print 1 and return the max element of priority queue, and then delete the max element. If not present, print -1.First line contains N, number of elements to be inserted into the Priority Queue. Second line contains N positive integers separated by space. Third line contains M, fourth line contains M positive integers.

Constraints:

1 <= M <= N <= 10^3
1 <= Arr[i] <= 10^3For each query, print "1" and max element in newlines if element to be found is present in the PriorityQueue, else print "-1". (use new line for each output, as shown in example)Sample Input:
1
8
1 2 3 4 5 2 3 1
5
1 3 2 9 10

Sample Output:
1
5
1
4
1
3
-1
-1, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int size1 = Integer.parseInt(br.readLine());
	PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
    HashMap<Integer,Integer> hm = new HashMap<>();
	String str[] = br.readLine().split(" ");
	int i=0;
	while(i!=size1)
	{

		pq.add(Integer.parseInt(str[i]));
		if(hm.containsKey(Integer.parseInt(str[i])))
		{
			int count = hm.get(Integer.parseInt(str[i]));
			hm.remove(Integer.parseInt(str[i]));
			hm.put(Integer.parseInt(str[i]),count+1);
		}
		else{
			hm.put(Integer.parseInt(str[i]),1);
		}
		i++;
	}

	size1 = Integer.parseInt(br.readLine());
	str = br.readLine().split(" ");
	i=0;
	while(i!=size1)
	{

		if(hm.containsKey(Integer.parseInt(str[i])))
		{
			System.out.println("1");
			System.out.println(pq.peek());
			int count = hm.get(pq.peek());
			if(count>1)
			  hm.put(pq.peek(),count-1);
			else
			  hm.remove(pq.peek());
			if(pq.size()>0)
			   pq.remove();
		}
		else{
			System.out.println("-1");
		}
		i++;
	}
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?