結果

問題 No.112 ややこしい鶴亀算
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-30 11:58:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 925 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 77,236 KB
実行使用メモリ 53,248 KB
最終ジャッジ日時 2023-10-11 23:34:20
合計ジャッジ時間 5,649 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
52,036 KB
testcase_01 AC 75 ms
50,692 KB
testcase_02 AC 86 ms
52,340 KB
testcase_03 AC 75 ms
51,040 KB
testcase_04 AC 78 ms
52,176 KB
testcase_05 AC 76 ms
50,736 KB
testcase_06 AC 79 ms
52,404 KB
testcase_07 AC 77 ms
50,620 KB
testcase_08 AC 77 ms
52,384 KB
testcase_09 AC 76 ms
52,276 KB
testcase_10 AC 78 ms
53,248 KB
testcase_11 AC 84 ms
52,188 KB
testcase_12 AC 76 ms
50,944 KB
testcase_13 AC 75 ms
50,832 KB
testcase_14 AC 76 ms
48,932 KB
testcase_15 AC 78 ms
52,164 KB
testcase_16 AC 74 ms
50,756 KB
testcase_17 AC 75 ms
51,036 KB
testcase_18 AC 90 ms
52,328 KB
testcase_19 AC 75 ms
52,268 KB
testcase_20 AC 75 ms
51,036 KB
testcase_21 AC 73 ms
48,812 KB
testcase_22 AC 78 ms
52,268 KB
testcase_23 AC 73 ms
50,584 KB
testcase_24 AC 74 ms
49,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        int sum = 0;
        String[] inputs = reader.readLine().split(" ");
        int[] legsArr = new int[N];
        for (int i = 0; i < N; i++) {
            int legs = Integer.parseInt(inputs[i]);
            sum += legs;
            legsArr[i] = legs;
        }
        sum = sum / (N - 1);
        int turtle=0;
        int cranes =0;

        for (int i = 0; i < N; i++) {
            if((sum-legsArr[i])%4 ==0) {
                turtle+=1;
            } else {
                cranes+=1;
            }
        }
        System.out.println(cranes +" " + turtle);
    }
}
0