結果

問題 No.21 平均の差
ユーザー 明智重蔵明智重蔵
提出日時 2015-08-02 18:50:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 1,685 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 105,112 KB
実行使用メモリ 24,000 KB
最終ジャッジ日時 2023-09-25 00:34:30
合計ジャッジ時間 3,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
22,012 KB
testcase_01 AC 64 ms
21,960 KB
testcase_02 AC 63 ms
23,932 KB
testcase_03 AC 64 ms
22,032 KB
testcase_04 AC 64 ms
22,028 KB
testcase_05 AC 64 ms
21,916 KB
testcase_06 AC 64 ms
21,956 KB
testcase_07 AC 64 ms
23,952 KB
testcase_08 AC 64 ms
23,936 KB
testcase_09 AC 64 ms
24,000 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input3";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("3");
            WillReturn.Add("555");
            WillReturn.Add("20");
            WillReturn.Add("432");
            WillReturn.Add("301");
            WillReturn.Add("21");
            //535
            //例えば {{555},{21,20},{433,301}} のようにグループ分けすると
            //平均は {555/1,(21+20)/2,(432+301)/2}={555,20.5,366.5} なので
            //最大の平均 - 最小の平均は 555 − 20.5 = 534.5
            //最後に小数点以下を切り上げて535
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8");
            WillReturn.Add("4");
            WillReturn.Add("329");
            WillReturn.Add("980");
            WillReturn.Add("656");
            WillReturn.Add("738");
            WillReturn.Add("739");
            WillReturn.Add("542");
            WillReturn.Add("873");
            WillReturn.Add("501");
            //651
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] NArr = InputList.Skip(2).Select(X => int.Parse(X)).ToArray();
        int MaxAvg = NArr.Max();
        int MinAvg = NArr.Min();
        Console.WriteLine(MaxAvg - MinAvg);
    }
}
0