結果
| 問題 | No.570 3人兄弟(その1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-03-26 20:48:02 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 135 ms / 2,000 ms | 
| コード長 | 1,112 bytes | 
| コンパイル時間 | 2,606 ms | 
| コンパイル使用メモリ | 80,768 KB | 
| 実行使用メモリ | 41,428 KB | 
| 最終ジャッジ日時 | 2024-06-25 07:24:27 | 
| 合計ジャッジ時間 | 4,056 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 | 
ソースコード
package net.ipipip0129.yukicoder.no570;
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++) humanList.add(new Human(names[i], Integer.parseInt(scan.nextLine())));
        Collections.sort(humanList, new HumanComparator());
        humanList.stream().forEach(i -> System.out.println(i.getName()));
    }
}
class Human {
    private String name;
    private int height;
    public Human(String name, int height) {
        this.name = name;
        this.height = height;
    }
    public String getName() {
        return name;
    }
    public int getHeight() {
        return height;
    }
}
class HumanComparator implements Comparator<Human> {
    @Override
    public int compare(Human o1, Human o2) {
        if (o1.getHeight() < o2.getHeight()) {
            return 1;
        } else {
            return -1;
        }
    }
}
            
            
            
        