forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe2930.java
More file actions
46 lines (37 loc) · 1.03 KB
/
swe2930.java
File metadata and controls
46 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.Collections;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;
public class swe2930 {
static Scanner sc = new Scanner(System.in);
static int K;
static int N;
static String answer = "";
static PriorityQueue<Integer> PQ = new PriorityQueue<>(Collections.reverseOrder());
public static void main(String[] args) {
int t = sc.nextInt();
//N개의 퀸이 N*N배열
for(int T=1; T<=t; T++) {
N = sc.nextInt();
answer = "";
PQ.clear();
solution();
System.out.println("#" + T + answer);
}
}
public static void solution()
{
for(int n=0; n<N; n++) {
int operation = sc.nextInt();
if( operation == 1) {
PQ.add(sc.nextInt());
continue;
}
if( PQ.isEmpty() ) {
answer += " -1";
continue;
}
answer += " " + PQ.poll();
}
}
}