結果

問題 No.112 ややこしい鶴亀算
ユーザー tentententen
提出日時 2020-11-05 18:52:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 5,313 ms
コンパイル使用メモリ 78,848 KB
実行使用メモリ 58,816 KB
最終ジャッジ日時 2023-09-29 17:14:35
合計ジャッジ時間 10,475 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
56,924 KB
testcase_01 AC 154 ms
56,704 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 154 ms
56,740 KB
testcase_05 AC 154 ms
56,988 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 154 ms
56,904 KB
testcase_09 AC 154 ms
56,744 KB
testcase_10 WA -
testcase_11 AC 153 ms
56,836 KB
testcase_12 WA -
testcase_13 AC 154 ms
56,564 KB
testcase_14 AC 159 ms
56,792 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 158 ms
56,796 KB
testcase_20 AC 158 ms
56,288 KB
testcase_21 WA -
testcase_22 AC 163 ms
56,532 KB
testcase_23 WA -
testcase_24 AC 160 ms
56,772 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.firstEntry().getValue();
		    turtle = map.lastEntry().getValue();
		}
		System.out.println(bird + " " + turtle);
	}
}
0