結果
| 問題 |
No.21 平均の差
|
| ユーザー |
明智重蔵
|
| 提出日時 | 2015-08-02 18:50:00 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 5,000 ms |
| コード長 | 1,685 bytes |
| コンパイル時間 | 911 ms |
| コンパイル使用メモリ | 113,100 KB |
| 実行使用メモリ | 27,172 KB |
| 最終ジャッジ日時 | 2024-07-18 00:48:56 |
| 合計ジャッジ時間 | 1,539 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}
明智重蔵