結果
問題 | No.571 3人兄弟(その2) |
ユーザー |
|
提出日時 | 2018-03-26 20:33:21 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 1,506 bytes |
コンパイル時間 | 2,506 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 41,480 KB |
最終ジャッジ日時 | 2024-06-25 07:23:21 |
合計ジャッジ時間 | 5,161 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
package net.ipipip0129.yukicoder.no571;import java.util.*;public class Main {public static void main(String[] args) {Scanner scan = new Scanner(System.in);List<Human> humanList = new ArrayList<>();final String[] names = new String[] {"A", "B", "C"};for (int i = 0; i < 3; i++) {String[] datas = scan.nextLine().split(" ");humanList.add(new Human(names[i], Integer.parseInt(datas[0]), Integer.parseInt(datas[1])));}Collections.sort(humanList, new HumanComparator());humanList.stream().forEach(i -> System.out.println(i.getName()));}}class Human {private String name;private int height;private int weight;public Human(String name, int height, int weight) {this.name = name;this.height = height;this.weight = weight;}public String getName() { return name; }public int getHeight() { return height; }public int getWeight() { return weight; }}class HumanComparator implements Comparator<Human> {@Overridepublic int compare(Human o1, Human o2) {if (o1.getHeight() < o2.getHeight()) {return 1;} else if(o1.getHeight() == o2.getHeight()) {if (o2.getWeight() < o1.getWeight()) {return 1;}else {return -1;}} else {return -1;}}}