結果

問題 No.571 3人兄弟(その2)
ユーザー tentententen
提出日時 2020-09-07 20:39:23
言語 Java19
(openjdk 21)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 1,000 bytes
コンパイル時間 2,319 ms
コンパイル使用メモリ 71,876 KB
実行使用メモリ 56,548 KB
最終ジャッジ日時 2023-08-19 17:08:57
合計ジャッジ時間 5,512 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,736 KB
testcase_01 AC 121 ms
55,848 KB
testcase_02 AC 115 ms
55,500 KB
testcase_03 AC 121 ms
55,716 KB
testcase_04 AC 121 ms
56,548 KB
testcase_05 AC 119 ms
55,936 KB
testcase_06 AC 120 ms
55,704 KB
testcase_07 AC 118 ms
55,856 KB
testcase_08 AC 119 ms
55,948 KB
testcase_09 AC 118 ms
55,760 KB
testcase_10 AC 120 ms
56,004 KB
testcase_11 AC 121 ms
55,720 KB
testcase_12 AC 122 ms
55,728 KB
testcase_13 AC 120 ms
55,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	Person[] arr = new Person[3];
    	for (int i = 0; i < 3; i++) {
    	    arr[i] = new Person((char)(i + 'A'), sc.nextInt(), sc.nextInt());
    	}
    	Arrays.sort(arr);
    	StringBuilder sb = new StringBuilder();
    	for (Person p : arr) {
    	    sb.append(p.name).append("\n");
    	}
    	System.out.print(sb);
    }
    
    static class Person implements Comparable<Person> {
        char name;
        int height;
        int weight;
        
        public Person(char name, int height, int weight) {
            this.name = name;
            this.height = height;
            this.weight = weight;
        }
        
        public int compareTo(Person another) {
            if (height == another.height) {
                return weight - another.weight;
            } else {
                return another.height - height;
            }
        }
    }

}
0