結果

問題 No.112 ややこしい鶴亀算
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-17 16:23:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 750 bytes
コンパイル時間 2,362 ms
コンパイル使用メモリ 75,932 KB
実行使用メモリ 57,808 KB
最終ジャッジ日時 2023-09-06 17:47:37
合計ジャッジ時間 6,869 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
56,804 KB
testcase_01 AC 133 ms
57,808 KB
testcase_02 AC 145 ms
56,968 KB
testcase_03 AC 147 ms
56,796 KB
testcase_04 AC 132 ms
56,244 KB
testcase_05 AC 132 ms
56,156 KB
testcase_06 AC 144 ms
56,676 KB
testcase_07 AC 144 ms
57,068 KB
testcase_08 AC 131 ms
56,432 KB
testcase_09 AC 132 ms
56,232 KB
testcase_10 AC 144 ms
56,904 KB
testcase_11 AC 144 ms
56,876 KB
testcase_12 AC 143 ms
56,896 KB
testcase_13 AC 131 ms
55,852 KB
testcase_14 AC 138 ms
55,900 KB
testcase_15 AC 149 ms
56,780 KB
testcase_16 AC 151 ms
56,900 KB
testcase_17 AC 151 ms
56,896 KB
testcase_18 AC 152 ms
56,812 KB
testcase_19 AC 141 ms
55,820 KB
testcase_20 AC 136 ms
56,244 KB
testcase_21 AC 149 ms
56,868 KB
testcase_22 AC 152 ms
56,896 KB
testcase_23 AC 153 ms
56,544 KB
testcase_24 AC 142 ms
56,024 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(max_num+" "+min_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