結果
問題 |
No.571 3人兄弟(その2)
|
ユーザー |
![]() |
提出日時 | 2017-10-28 17:25:12 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 130 ms / 2,000 ms |
コード長 | 1,031 bytes |
コンパイル時間 | 2,407 ms |
コンパイル使用メモリ | 77,784 KB |
実行使用メモリ | 41,496 KB |
最終ジャッジ日時 | 2024-11-22 03:38:26 |
合計ジャッジ時間 | 4,686 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static class Person implements Comparable<Person> { 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); } } }