結果
問題 |
No.21 平均の差
|
ユーザー |
|
提出日時 | 2019-01-09 14:47:21 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 1,275 bytes |
コンパイル時間 | 800 ms |
コンパイル使用メモリ | 103,808 KB |
実行使用メモリ | 17,664 KB |
最終ジャッジ日時 | 2024-11-24 00:55:31 |
合計ジャッジ時間 | 1,547 ms |
ジャッジサーバーID (参考情報) |
judge5 / 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; namespace No021 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); int[] num = new int[n]; double max = 0.0, min = 1000.0; for (int i = 0; i < n; i++) num[i] = int.Parse(Console.ReadLine()); for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++) Search(num, i, j, ref max, ref min); Console.WriteLine((int)Math.Ceiling(max - min)); } static void Search(int[] num, int a, int b, ref double max, ref double min) { for (int i = 0; i < num.Length - 1; i++) { int sum = 0, count = 0; for (int j = i; j < num.Length; j++) { if (j == a || j == b) continue; sum += num[j]; count++; double ave = (double)sum / (double)count; if (max < ave) max = ave; if (min > ave) min = ave; } } } } }