import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.io.*;
import java.util.*;
/*
* Create the Student and Priorities classes here.
*/
class Student{
int id;
String name;
double cgpa;
public Student(int id, String name, double cgpa){
this.id = id;
this.name = name;
this.cgpa = cgpa;
}
int getID(){
return this.id;
}
String getName(){
return this.name;
}
double getCGPA(){
return this.cgpa;
}
}
class Priorities{
static List<Student> getStudents(List<String> events){
List <Student> solution = new LinkedList<>();
PriorityQueue<Student> helper = new PriorityQueue<>(
Comparator
.comparing(Student::getCGPA).reversed()
.thenComparing(Student::getName)
.thenComparing(Student::getID)
); //MinHeap
for(String event: events){
String[] actualEvent = event.split(" ");
if(actualEvent[0].equals("ENTER")){
//added to queue
helper.add(new Student(Integer.parseInt(actualEvent[3]), actualEvent[1], Double.parseDouble(actualEvent[2])));
}else{
//removed from queue
helper.poll();
}
}
while(!helper.isEmpty()){
solution.add(helper.poll());
}
return solution;
}
}