結果
| 問題 |
No.21 平均の差
|
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-10 21:34:11 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 5,000 ms |
| コード長 | 1,682 bytes |
| コンパイル時間 | 1,197 ms |
| コンパイル使用メモリ | 112,544 KB |
| 実行使用メモリ | 27,108 KB |
| 最終ジャッジ日時 | 2024-10-10 21:34:13 |
| 合計ジャッジ時間 | 1,873 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = "InputX";
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);
}
}
aketijyuuzou