結果
問題 | No.21 平均の差 |
ユーザー | Himatsubushin |
提出日時 | 2019-01-09 14:47:21 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 1,275 bytes |
コンパイル時間 | 4,084 ms |
コンパイル使用メモリ | 102,356 KB |
実行使用メモリ | 22,736 KB |
最終ジャッジ日時 | 2023-08-15 16:54:10 |
合計ジャッジ時間 | 3,093 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
22,672 KB |
testcase_01 | AC | 56 ms
22,728 KB |
testcase_02 | AC | 54 ms
22,736 KB |
testcase_03 | AC | 53 ms
20,620 KB |
testcase_04 | AC | 53 ms
20,872 KB |
testcase_05 | AC | 53 ms
20,636 KB |
testcase_06 | AC | 55 ms
20,888 KB |
testcase_07 | AC | 54 ms
20,744 KB |
testcase_08 | AC | 54 ms
22,604 KB |
testcase_09 | AC | 55 ms
20,732 KB |
コンパイルメッセージ
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; } } } } }