結果

問題 No.112 ややこしい鶴亀算
ユーザー Aru hokodateAru hokodate
提出日時 2018-10-18 17:59:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 3,167 ms
コンパイル使用メモリ 75,976 KB
実行使用メモリ 42,716 KB
最終ジャッジ日時 2024-04-24 12:21:35
合計ジャッジ時間 7,401 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,968 KB
testcase_01 AC 133 ms
42,436 KB
testcase_02 AC 134 ms
42,252 KB
testcase_03 AC 126 ms
41,644 KB
testcase_04 AC 131 ms
42,048 KB
testcase_05 AC 129 ms
41,800 KB
testcase_06 AC 123 ms
42,252 KB
testcase_07 WA -
testcase_08 AC 140 ms
42,168 KB
testcase_09 AC 136 ms
42,252 KB
testcase_10 AC 139 ms
42,372 KB
testcase_11 AC 127 ms
41,980 KB
testcase_12 AC 134 ms
42,272 KB
testcase_13 AC 126 ms
42,376 KB
testcase_14 AC 136 ms
41,372 KB
testcase_15 AC 134 ms
42,384 KB
testcase_16 AC 142 ms
41,644 KB
testcase_17 WA -
testcase_18 AC 137 ms
42,584 KB
testcase_19 AC 136 ms
42,716 KB
testcase_20 AC 139 ms
42,120 KB
testcase_21 AC 125 ms
41,860 KB
testcase_22 AC 136 ms
41,560 KB
testcase_23 AC 154 ms
42,480 KB
testcase_24 AC 137 ms
42,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yuki4 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int leg[] = new int[n];
        int x = 0;
        int y = 0;
        int z = -1;
        for (int i = 0; i < n; i++) {
            leg[i] = scan.nextInt();
        }

        for (int i = 0; i < n; i++) {
            if (leg[0] == leg[i]) x++;
            else z = i;
        }
        y = n - x;

        if (2 * x + 4 * y == leg[0] + 2) {
            if (z == -1) System.out.println(x + " " + y);
            else if (2 * x + 4 * y == leg[z] + 4) System.out.println(x + " " + y);
        }
        else System.out.println(y + " " + x);
    }
}
0