結果

問題 No.112 ややこしい鶴亀算
ユーザー tentententen
提出日時 2020-11-05 18:53:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 5,000 ms
コード長 657 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 74,892 KB
実行使用メモリ 58,536 KB
最終ジャッジ日時 2023-09-29 17:14:48
合計ジャッジ時間 7,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
56,748 KB
testcase_01 AC 158 ms
56,752 KB
testcase_02 AC 155 ms
56,836 KB
testcase_03 AC 157 ms
56,608 KB
testcase_04 AC 156 ms
56,580 KB
testcase_05 AC 156 ms
56,816 KB
testcase_06 AC 159 ms
56,520 KB
testcase_07 AC 157 ms
56,636 KB
testcase_08 AC 158 ms
56,612 KB
testcase_09 AC 156 ms
56,820 KB
testcase_10 AC 155 ms
56,904 KB
testcase_11 AC 157 ms
56,880 KB
testcase_12 AC 157 ms
56,780 KB
testcase_13 AC 156 ms
56,788 KB
testcase_14 AC 166 ms
56,804 KB
testcase_15 AC 163 ms
58,536 KB
testcase_16 AC 165 ms
57,076 KB
testcase_17 AC 167 ms
56,588 KB
testcase_18 AC 162 ms
56,596 KB
testcase_19 AC 165 ms
56,936 KB
testcase_20 AC 164 ms
56,556 KB
testcase_21 AC 162 ms
56,300 KB
testcase_22 AC 164 ms
56,588 KB
testcase_23 AC 163 ms
56,592 KB
testcase_24 AC 163 ms
56,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    map.put(x, map.getOrDefault(x, 0) + 1);
		}
		int bird;
		int turtle;
		if (map.size() == 1) {
		    if (map.firstKey() / (n - 1) == 2) {
		        bird = n;
		        turtle = 0;
		    } else {
		        bird = 0;
		        turtle = n;
		    }
		} else {
		    bird = map.lastEntry().getValue();
		    turtle = map.firstEntry().getValue();
		}
		System.out.println(bird + " " + turtle);
	}
}
0