import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.util.Scanner;
import java.io.InputStreamReader;
import java.lang.Comparable;
import java.util.Arrays;
class Mouse implements Comparable<Mouse>
{
public int weight;
public String color;
public Mouse(int w, String c)
{
weight = w;
color = c;
}
public int compareTo(Mouse other)
{
return other.weight - weight;
}
}
class Main
{
public static final boolean DEBUG = false;
public static void main(String[] args) throws IOException
{
Scanner cin;
int n;
if (DEBUG) {
cin = new Scanner(new FileReader("d:\\OJ\\uva_in.txt"));
} else {
cin = new Scanner(System.in);
}
while (cin.hasNext()) {
n = cin.nextInt();
Mouse[] mouse = new Mouse[n];
for (int i = 0; i < n; i++) {
String s;
int w;
w = cin.nextInt();
s = cin.next();
mouse[i] = new Mouse(w, s);
}
Arrays.sort(mouse);
for (int i = 0; i < n; i++) {
System.out.println(mouse[i].color);
}
}
}
}
题目1110:小白鼠排队
最新推荐文章于 2020-10-16 21:57:29 发布