結果

問題 No.112 ややこしい鶴亀算
ユーザー Tsukasa_Type
提出日時 2018-02-17 16:23:36
言語 Java
(openjdk 23)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 750 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 79,504 KB
実行使用メモリ 54,952 KB
最終ジャッジ日時 2024-06-24 12:13:07
合計ジャッジ時間 7,068 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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