結果

問題 No.21 平均の差
ユーザー SagTokiSagToki
提出日時 2018-06-07 16:01:24
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 862 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 103,216 KB
実行使用メモリ 22,800 KB
最終ジャッジ日時 2023-09-12 23:02:52
合計ジャッジ時間 3,468 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
22,568 KB
testcase_01 AC 55 ms
20,596 KB
testcase_02 AC 57 ms
20,704 KB
testcase_03 AC 57 ms
22,800 KB
testcase_04 AC 56 ms
20,620 KB
testcase_05 AC 58 ms
22,556 KB
testcase_06 AC 57 ms
20,748 KB
testcase_07 AC 57 ms
22,688 KB
testcase_08 AC 58 ms
22,688 KB
testcase_09 AC 56 ms
20,728 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace ConsoleApp5 {
    class Program {
        static void Main(string[] args) {
            int N = Input(3, 9);
            int K = Input(3, N);
            int[] n = new int[N];
            for(int i = 0; i < N; i++) {
                n[i] = Input(1, 1000);
            }
            Array.Sort(n);
            int Answer = n[N - 1] - n[0];
            Console.WriteLine(Answer);
        }

        static int Input(int Min , int Max) {
            int Number = int.Parse(Console.ReadLine());
            try {
                if (Number < Min || Number > Max) {
                    Console.WriteLine(Min + "以上" + Max + "以下で入力してください");
                }
            }catch(Exception E) { 
                Console.WriteLine("想定外のエラーです");
            }
            return Number;
        }
    }
}
0