結果

問題 No.112 ややこしい鶴亀算
ユーザー tsunabittsunabit
提出日時 2019-05-06 10:52:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 3,820 ms
コンパイル使用メモリ 76,016 KB
実行使用メモリ 58,592 KB
最終ジャッジ日時 2023-09-09 12:21:27
合計ジャッジ時間 8,970 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
56,732 KB
testcase_01 AC 137 ms
56,176 KB
testcase_02 AC 150 ms
56,460 KB
testcase_03 AC 148 ms
56,688 KB
testcase_04 AC 135 ms
55,780 KB
testcase_05 AC 135 ms
55,700 KB
testcase_06 AC 149 ms
56,676 KB
testcase_07 AC 150 ms
56,528 KB
testcase_08 AC 135 ms
55,500 KB
testcase_09 AC 136 ms
55,660 KB
testcase_10 AC 151 ms
56,696 KB
testcase_11 AC 150 ms
56,876 KB
testcase_12 AC 150 ms
58,592 KB
testcase_13 AC 135 ms
56,068 KB
testcase_14 AC 141 ms
55,764 KB
testcase_15 AC 155 ms
56,708 KB
testcase_16 AC 155 ms
56,504 KB
testcase_17 AC 156 ms
56,456 KB
testcase_18 AC 155 ms
56,500 KB
testcase_19 AC 142 ms
55,488 KB
testcase_20 AC 142 ms
55,728 KB
testcase_21 AC 154 ms
56,436 KB
testcase_22 AC 154 ms
56,696 KB
testcase_23 AC 154 ms
56,508 KB
testcase_24 AC 140 ms
55,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No112 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        
        int min = a[0];
		int max = a[0];
		for(int i = 1; i < n; i++) {
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i]);
		}
		
		if(max == min) {
			if((max / (n-1)) == 4) System.out.println(0 + " " + n);
			else System.out.println(n + " " + 0);
		}else {
			int kame = 0, tsuru = 0;
			for(int i = 0; i < n; i++) {
				if(a[i] == max) kame++;
				else tsuru++;
			}
			System.out.println(kame + " " + tsuru);
		}
    }
}
0