結果

問題 No.112 ややこしい鶴亀算
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-15 02:17:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 5,000 ms
コード長 734 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 77,376 KB
実行使用メモリ 58,440 KB
最終ジャッジ日時 2023-10-22 05:28:06
合計ジャッジ時間 7,560 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
57,596 KB
testcase_01 AC 143 ms
57,876 KB
testcase_02 AC 153 ms
58,272 KB
testcase_03 AC 153 ms
58,116 KB
testcase_04 AC 143 ms
57,916 KB
testcase_05 AC 145 ms
57,696 KB
testcase_06 AC 150 ms
58,204 KB
testcase_07 AC 152 ms
58,068 KB
testcase_08 AC 152 ms
58,256 KB
testcase_09 AC 151 ms
58,068 KB
testcase_10 AC 151 ms
58,128 KB
testcase_11 AC 152 ms
58,164 KB
testcase_12 AC 151 ms
58,380 KB
testcase_13 AC 140 ms
57,856 KB
testcase_14 AC 155 ms
58,260 KB
testcase_15 AC 158 ms
58,252 KB
testcase_16 AC 157 ms
58,132 KB
testcase_17 AC 157 ms
58,356 KB
testcase_18 AC 159 ms
58,416 KB
testcase_19 AC 148 ms
57,812 KB
testcase_20 AC 159 ms
58,440 KB
testcase_21 AC 149 ms
57,756 KB
testcase_22 AC 157 ms
56,360 KB
testcase_23 AC 146 ms
57,752 KB
testcase_24 AC 160 ms
58,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        in.close();

        int c_num = 0; //crane
        int t_num = 0; //turtle
        int sum = 0;

        for(int i=0; i<n; i++) {
            sum += a[i];
        }

        sum = sum / (n - 1);

        for(int i=0; i<n; i++) {
            if(sum - a[i] == 2) {
                c_num++;
            }
            if(sum - a[i] == 4) {
                t_num++;
            }
        }

        System.out.println(c_num + " " + t_num);
    }
}
0