結果
問題 | No.571 3人兄弟(その2) |
ユーザー | fukusei |
提出日時 | 2018-05-05 16:43:47 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 130 ms / 2,000 ms |
コード長 | 1,307 bytes |
コンパイル時間 | 2,303 ms |
コンパイル使用メモリ | 77,920 KB |
実行使用メモリ | 56,124 KB |
最終ジャッジ日時 | 2023-09-10 10:34:10 |
合計ジャッジ時間 | 5,115 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
55,940 KB |
testcase_01 | AC | 129 ms
56,048 KB |
testcase_02 | AC | 129 ms
56,000 KB |
testcase_03 | AC | 126 ms
55,696 KB |
testcase_04 | AC | 127 ms
55,832 KB |
testcase_05 | AC | 129 ms
55,544 KB |
testcase_06 | AC | 129 ms
55,680 KB |
testcase_07 | AC | 130 ms
55,972 KB |
testcase_08 | AC | 128 ms
55,832 KB |
testcase_09 | AC | 128 ms
55,860 KB |
testcase_10 | AC | 128 ms
56,124 KB |
testcase_11 | AC | 128 ms
55,592 KB |
testcase_12 | AC | 130 ms
55,824 KB |
testcase_13 | AC | 126 ms
55,832 KB |
ソースコード
import java.util.Arrays; import java.util.Scanner; class Brother { int cm; int kg; String name; public Brother(int cm, int kg ,String name) { this.cm = cm; this.kg = kg; this.name = name; } } class paiza { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Brother[] brother = new Brother[3]; boolean check = false; Brother tmp; //Brother[] sort = new Brother[3]; String[] index = {"A","B","C"}; for (int i = 0; i < 3; i++) { brother[i] = new Brother(sc.nextInt(),sc.nextInt(),index[i]); } do { check = false; if (brother[0].cm == brother[1].cm) { if(brother[0].kg > brother[1].kg) { tmp = brother[0]; brother[0] = brother[1]; brother[1] = tmp; check = true; } } if (brother[1].cm == brother[2].cm) { if(brother[1].kg > brother[2].kg) { tmp = brother[1]; brother[1] = brother[2]; brother[2] = tmp; check = true; } } if (brother[0].cm == brother[2].cm) { if(brother[0].kg > brother[2].kg) { tmp = brother[2]; brother[2] = brother[0]; brother[0] = tmp; check = true; } } } while (check); Arrays.sort( brother, (a,b)-> b.cm - a.cm ); for(int i = 0; i < brother.length; i++) { System.out.println(brother[i].name); } } }