結果

問題 No.112 ややこしい鶴亀算
ユーザー bayashiko_rbayashiko_r
提出日時 2018-11-14 00:35:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 1,308 bytes
コンパイル時間 2,158 ms
コンパイル使用メモリ 104,684 KB
実行使用メモリ 24,796 KB
最終ジャッジ日時 2023-08-26 00:59:45
合計ジャッジ時間 5,099 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,712 KB
testcase_01 AC 56 ms
20,560 KB
testcase_02 AC 56 ms
20,628 KB
testcase_03 AC 57 ms
20,776 KB
testcase_04 AC 58 ms
24,796 KB
testcase_05 AC 57 ms
22,760 KB
testcase_06 AC 56 ms
20,628 KB
testcase_07 AC 57 ms
18,688 KB
testcase_08 AC 56 ms
20,876 KB
testcase_09 AC 58 ms
22,716 KB
testcase_10 AC 56 ms
20,768 KB
testcase_11 AC 57 ms
22,708 KB
testcase_12 AC 57 ms
20,820 KB
testcase_13 AC 56 ms
18,544 KB
testcase_14 AC 56 ms
20,780 KB
testcase_15 AC 57 ms
20,712 KB
testcase_16 AC 57 ms
22,760 KB
testcase_17 AC 57 ms
20,664 KB
testcase_18 AC 57 ms
20,792 KB
testcase_19 AC 58 ms
20,824 KB
testcase_20 AC 57 ms
20,756 KB
testcase_21 AC 57 ms
22,720 KB
testcase_22 AC 56 ms
20,704 KB
testcase_23 AC 57 ms
22,752 KB
testcase_24 AC 57 ms
22,692 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());

        string s = Console.ReadLine();
        string[] t = s.Split(' ');

        int[] a = new int[N];

        //数字の割り当て
        for (int i = 0; i < N; i++) {
            a[i] = int.Parse(t[i]);
        }

        //全体の和を求める
        int sum = 0;
        int max = 0;

        //全部同じ数字かどうか
        bool isSame = true;

        //数字の中で、最大のものを求める
        for (int i = 0; i < N; i++) {
            max = Math.Max(max, a[i]);
        }

        for (int i = 0; i < N; i++) {
            if (a[i] != max) {
                isSame = false;
            }
        }

        //全て同じとき
        if (isSame == true) {
            if (max / (N - 1) == 2) {
                sum = max + 2;
            } else if (max / (N - 1) == 4) {
                sum = max + 4;
            }
        //全て同じではないとき
        } else if (isSame == false) {
            sum = max + 2;
        }

        //鶴と亀の数
        int tsuru;
        int kame;

        tsuru = (4 * N - sum) / 2;
        kame = N - tsuru;

        //出力
        Console.WriteLine(tsuru + " " + kame);
    }
}
0