[Java]
Package D0725;
Import java. util .*;
Public class HDU1873 {
Public static void main (String [] args ){
Pipeline SC = new pipeline (System. in );
Int n;
Parameter List <Patient> list1;
Parameter List <Patient> list2;
Parameter List <Patient> list3;
While (SC. hasNext ()){
N = SC. nextInt ();
List1 = new parameter list <Patient> ();
List2 = new parameter list <Patient> ();
List3 = new parameter list <Patient> ();
Int id = 1;
While (n --> 0 ){
String str = SC. next ();
// In
If (str. charAt (0) = 'I '){
Int docid = SC. nextInt ();
Int priority = SC. nextInt ();
Patient p = new Patient (id ++, docid, priority );
If (docid = 1 ){
List1.add (p );
Collections. sort (list1 );
} Else if (docid = 2 ){
List2.add (p );
Collections. sort (list2 );
} Else {
List3.add (p );
Collections. sort (list3 );
}
} Else {// out
Int docid = SC. nextInt ();
If (docid = 1 ){
If (list1.isEmpty ())
System. out. println ("EMPTY ");
Else
System. out. println (list1.poll (). id );
} Else if (docid = 2 ){
If (list2.isEmpty ())
System. out. println ("EMPTY ");
Else
System. out. println (list2.poll (). id );
} Else {
If (list3.isEmpty ())
System. out. println ("EMPTY ");
Else
System. out. println (list3.poll (). id );
}
}
}
}
}
}
Class Patient implements Comparable <Patient> {
Public int docId;
Public int priority;
Public int id;
Public Patient (int id, int docId, int priority ){
This. id = id;
This.doc Id = docId;
This. priority = priority;
}
@ Override
Public int compareTo (Patient o ){
If (this. priority> = o. priority)
Return-1;
Return 1;
}
} [Java]
Package D0725;
Import java. util .*;
Public class HDU1873 {
Public static void main (String [] args ){
Pipeline SC = new pipeline (System. in );
Int n;
Parameter List <Patient> list1;
Parameter List <Patient> list2;
Parameter List <Patient> list3;
While (SC. hasNext ()){
N = SC. nextInt ();
List1 = new parameter list <Patient> ();
List2 = new parameter list <Patient> ();
List3 = new parameter list <Patient> ();
Int id = 1;
While (n --> 0 ){
String str = SC. next ();
// In
If (str. charAt (0) = 'I '){
Int docid = SC. nextInt ();
Int priority = SC. nextInt ();
Patient p = new Patient (id ++, docid, priority );
If (docid = 1 ){
List1.add (p );
Collections. sort (list1 );
} Else if (docid = 2 ){
List2.add (p );
Collections. sort (list2 );
} Else {
List3.add (p );
Collections. sort (list3 );
}
} Else {// out
Int docid = SC. nextInt ();
If (docid = 1 ){
If (list1.isEmpty ())
System. out. println ("EMPTY ");
Else
System. out. println (list1.poll (). id );
} Else if (docid = 2 ){
If (list2.isEmpty ())
System. out. println ("EMPTY ");
Else
System. out. println (list2.poll (). id );
} Else {
If (list3.isEmpty ())
System. out. println ("EMPTY ");
Else
System. out. println (list3.poll (). id );
}
}
}
}
}
}
Class Patient implements Comparable <Patient> {
Public int docId;
Public int priority;
Public int id;
Public Patient (int id, int docId, int priority ){
This. id = id;
This.doc Id = docId;
This. priority = priority;
}
@ Override
Public int compareTo (Patient o ){
If (this. priority> = o. priority)
Return-1;
Return 1;
}
}
Author: lhfight