結果

問題 No.571 3人兄弟(その2)
ユーザー uafr_csuafr_cs
提出日時 2017-10-28 17:25:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 3,034 ms
コンパイル使用メモリ 78,332 KB
実行使用メモリ 41,380 KB
最終ジャッジ日時 2024-05-01 21:08:14
合計ジャッジ時間 5,402 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,096 KB
testcase_01 AC 133 ms
41,196 KB
testcase_02 AC 133 ms
41,320 KB
testcase_03 AC 122 ms
40,240 KB
testcase_04 AC 134 ms
41,376 KB
testcase_05 AC 136 ms
41,140 KB
testcase_06 AC 133 ms
41,088 KB
testcase_07 AC 133 ms
41,264 KB
testcase_08 AC 130 ms
41,256 KB
testcase_09 AC 126 ms
40,388 KB
testcase_10 AC 134 ms
41,116 KB
testcase_11 AC 134 ms
41,380 KB
testcase_12 AC 133 ms
40,996 KB
testcase_13 AC 135 ms
41,300 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