結果

問題 No.571 3人兄弟(その2)
ユーザー uafr_csuafr_cs
提出日時 2017-10-28 17:25:12
言語 Java19
(openjdk 21)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 1,862 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 56,152 KB
最終ジャッジ日時 2023-08-14 08:36:28
合計ジャッジ時間 4,319 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
54,032 KB
testcase_01 AC 107 ms
55,728 KB
testcase_02 AC 109 ms
55,676 KB
testcase_03 AC 114 ms
55,728 KB
testcase_04 AC 111 ms
56,016 KB
testcase_05 AC 107 ms
55,656 KB
testcase_06 AC 112 ms
55,812 KB
testcase_07 AC 109 ms
55,888 KB
testcase_08 AC 112 ms
55,784 KB
testcase_09 AC 115 ms
56,152 KB
testcase_10 AC 109 ms
55,792 KB
testcase_11 AC 114 ms
56,008 KB
testcase_12 AC 111 ms
55,984 KB
testcase_13 AC 112 ms
55,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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