結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
56,476 KB
testcase_01 AC 134 ms
55,656 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 136 ms
55,432 KB
testcase_05 AC 134 ms
56,456 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 136 ms
56,052 KB
testcase_09 AC 135 ms
55,636 KB
testcase_10 WA -
testcase_11 AC 148 ms
57,036 KB
testcase_12 WA -
testcase_13 AC 134 ms
54,496 KB
testcase_14 AC 139 ms
55,792 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 138 ms
55,792 KB
testcase_20 AC 140 ms
55,788 KB
testcase_21 WA -
testcase_22 AC 153 ms
56,500 KB
testcase_23 WA -
testcase_24 AC 139 ms
55,560 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 = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		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 == max) {
			int species = min/(n-1);
			if (species == 2) {System.out.println(n+" "+0);}
			else if (species == 4) {System.out.println(0+" "+n);}
		}
	}
}
0