import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static class Person implements Comparable { String name; int height, weight; public Person(String name, int height, int weight){ this.name = name; this.height = height; this.weight = weight; } @Override public int compareTo(Person arg0){ if(Integer.compare(this.height, arg0.height) != 0){ return -Integer.compare(this.height, arg0.height); }else{ return Integer.compare(this.weight, arg0.weight); } } @Override public String toString(){ return this.name; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); Person[] people = new Person[3]; people[0] = new Person("A", sc.nextInt(), sc.nextInt()); people[1] = new Person("B", sc.nextInt(), sc.nextInt()); people[2] = new Person("C", sc.nextInt(), sc.nextInt()); Arrays.sort(people); for(final Person p : people){ System.out.println(p); } } }