結果

問題 No.21 平均の差
ユーザー n.yn.y
提出日時 2022-06-07 11:01:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 1,184 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 108,308 KB
実行使用メモリ 23,776 KB
最終ジャッジ日時 2023-10-21 03:48:31
合計ジャッジ時間 1,686 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,776 KB
testcase_01 AC 24 ms
23,776 KB
testcase_02 AC 23 ms
23,776 KB
testcase_03 AC 23 ms
23,776 KB
testcase_04 AC 23 ms
23,776 KB
testcase_05 AC 23 ms
23,776 KB
testcase_06 AC 23 ms
23,776 KB
testcase_07 AC 23 ms
23,776 KB
testcase_08 AC 23 ms
23,776 KB
testcase_09 AC 24 ms
23,776 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 yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //N行目
            int N = int.Parse(Console.ReadLine());
            //Kグループに振り分ける
            int K = int.Parse(Console.ReadLine());
            int[] a = new int[N];

            //nを配列に入れる
            for(int i=0;i<N;i++)
            {
                //数字 N個入力する
                int n = int.Parse(Console.ReadLine());
                a[i] = n;

            }

            //nを小さい順に並び替え
            for(int i=0;i<N;i++)
            {
                for(int j=0;j<i;j++)
                {
                    if (a[i - 1] > a[i])
                    {
                        int temp = a[i];
                        a[i] = a[i - 1];
                        a[i - 1] = temp;
                        i = 0; 
                    }
                }
            }

            int ans = 0;
            //ソートした最小と最大を引く
                ans = a[N-1] - a[0];


            //表示は文字列にする
            Console.WriteLine(ans.ToString());
        }
    }
}
0