結果

問題 No.570 3人兄弟(その1)
ユーザー Pump0129Pump0129
提出日時 2018-03-26 20:48:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 4,019 ms
コンパイル使用メモリ 83,752 KB
実行使用メモリ 55,972 KB
最終ジャッジ日時 2023-09-07 13:17:58
合計ジャッジ時間 4,800 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,836 KB
testcase_01 AC 129 ms
55,716 KB
testcase_02 AC 127 ms
55,652 KB
testcase_03 AC 128 ms
55,652 KB
testcase_04 AC 127 ms
55,780 KB
testcase_05 AC 126 ms
55,756 KB
testcase_06 AC 124 ms
55,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
        }
    }
}
0