結果

問題 No.112 ややこしい鶴亀算
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-17 16:19:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 75,464 KB
実行使用メモリ 59,100 KB
最終ジャッジ日時 2023-09-06 17:46:58
合計ジャッジ時間 6,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 142 ms
56,724 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 146 ms
56,664 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 145 ms
56,920 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 155 ms
56,760 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 150 ms
56,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] animal = new int[n];
		int min = 0;
		int max = 0;
		for (int i=0; i<n; i++) {
			animal[i] = sc.nextInt();
			min = Math.min(min,animal[i]);
			max = Math.max(max,animal[i]);
		}
		int min_num = 0;
		int max_num = 0;
		for (int i=0; i<n; i++) {
			if (animal[i]==min) {min_num++;}
			else if (animal[i]==max) {max_num++;}
		}
		if (min != max) {System.out.println(min_num+" "+max_num);}
		else if (min_num == max_num) {
			int species = min_num/(n-1);
			if (species == 2) {System.out.println(n+" "+0);}
			else if (species == 4) {System.out.println(0+" "+n);}
		}
	}
}
0