結果

問題 No.112 ややこしい鶴亀算
ユーザー kano_townkano_town
提出日時 2015-01-01 01:43:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 171 ms / 5,000 ms
コード長 581 bytes
コンパイル時間 5,133 ms
コンパイル使用メモリ 75,968 KB
実行使用メモリ 56,876 KB
最終ジャッジ日時 2023-09-03 20:20:04
合計ジャッジ時間 10,513 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
56,468 KB
testcase_01 AC 156 ms
56,528 KB
testcase_02 AC 159 ms
56,672 KB
testcase_03 AC 158 ms
56,540 KB
testcase_04 AC 157 ms
56,640 KB
testcase_05 AC 159 ms
56,424 KB
testcase_06 AC 160 ms
56,668 KB
testcase_07 AC 158 ms
56,652 KB
testcase_08 AC 158 ms
56,540 KB
testcase_09 AC 159 ms
56,644 KB
testcase_10 AC 160 ms
56,632 KB
testcase_11 AC 158 ms
56,540 KB
testcase_12 AC 159 ms
56,864 KB
testcase_13 AC 159 ms
56,852 KB
testcase_14 AC 165 ms
56,536 KB
testcase_15 AC 165 ms
56,324 KB
testcase_16 AC 167 ms
56,544 KB
testcase_17 AC 165 ms
56,520 KB
testcase_18 AC 171 ms
56,604 KB
testcase_19 AC 165 ms
56,568 KB
testcase_20 AC 165 ms
56,408 KB
testcase_21 AC 166 ms
56,580 KB
testcase_22 AC 167 ms
56,876 KB
testcase_23 AC 164 ms
56,760 KB
testcase_24 AC 163 ms
56,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder112 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), kame = 0, tsuru = 0;
		int[] a = new int[n];
		int max = -1, min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			max = Math.max(max, a[i]);
			min = Math.min(min, a[i]);
		}

		if (max == min)
			if (max / (n - 1) == 4) kame = n;
			else tsuru = n;
		else
			for (int i = 0; i < n; i++) {
				if (a[i] == max) tsuru++;
				else kame++;
			}
		System.out.println(tsuru + " " + kame);
	}
}
0