結果

問題 No.112 ややこしい鶴亀算
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-17 16:18:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 738 bytes
コンパイル時間 1,979 ms
コンパイル使用メモリ 76,404 KB
実行使用メモリ 59,112 KB
最終ジャッジ日時 2023-09-06 17:46:31
合計ジャッジ時間 7,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 150 ms
56,704 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 148 ms
56,628 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 156 ms
57,268 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 150 ms
56,820 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 157 ms
55,100 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_num != max_num) {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