結果

問題 No.112 ややこしい鶴亀算
ユーザー Aru hokodate
提出日時 2018-10-18 18:01:12
言語 Java
(openjdk 23)
結果
AC  
実行時間 170 ms / 5,000 ms
コード長 777 bytes
コンパイル時間 4,072 ms
コンパイル使用メモリ 76,612 KB
実行使用メモリ 55,216 KB
最終ジャッジ日時 2024-11-06 20:16:49
合計ジャッジ時間 9,023 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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