結果

問題 No.112 ややこしい鶴亀算
ユーザー Aru hokodateAru hokodate
提出日時 2018-10-18 18:01:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 777 bytes
コンパイル時間 3,032 ms
コンパイル使用メモリ 76,228 KB
実行使用メモリ 42,732 KB
最終ジャッジ日時 2024-04-24 12:24:56
合計ジャッジ時間 7,299 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
41,724 KB
testcase_01 AC 129 ms
42,356 KB
testcase_02 AC 121 ms
41,800 KB
testcase_03 AC 131 ms
42,240 KB
testcase_04 AC 132 ms
42,296 KB
testcase_05 AC 138 ms
42,196 KB
testcase_06 AC 135 ms
42,280 KB
testcase_07 AC 126 ms
42,192 KB
testcase_08 AC 142 ms
42,288 KB
testcase_09 AC 139 ms
42,552 KB
testcase_10 AC 137 ms
42,320 KB
testcase_11 AC 136 ms
42,168 KB
testcase_12 AC 134 ms
42,240 KB
testcase_13 AC 138 ms
42,228 KB
testcase_14 AC 142 ms
42,452 KB
testcase_15 AC 129 ms
40,888 KB
testcase_16 AC 126 ms
42,080 KB
testcase_17 AC 141 ms
42,484 KB
testcase_18 AC 139 ms
42,000 KB
testcase_19 AC 126 ms
42,028 KB
testcase_20 AC 148 ms
42,732 KB
testcase_21 AC 134 ms
42,648 KB
testcase_22 AC 145 ms
41,812 KB
testcase_23 AC 126 ms
42,216 KB
testcase_24 AC 136 ms
42,192 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);
        }
        else System.out.println(y + " " + x);
    }
}
0