結果

問題 No.21 平均の差
ユーザー funakoshifunakoshi
提出日時 2019-06-20 13:43:15
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,485 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 110,320 KB
実行使用メモリ 26,188 KB
最終ジャッジ日時 2024-05-09 19:01:14
合計ジャッジ時間 1,627 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            string k = Console.ReadLine();
            int num = int.Parse(n);
            int box = int.Parse(k);
            int loop = num - box;
            int[] ary = new int[num];
            for (int i=0;i<num;i++)
            {
                var line=Console.ReadLine();
                ary[i] = int.Parse(line);
            }
            
            for (int i = 0; i < ary.Length; i++)
            {

                for (int j = i + 1; j < ary.Length; j++)
                {
                    if(ary[i]<ary[j])
                    {
                        int temp = ary[i];
                        ary[i] = ary[j];
                        ary[j] = temp;
                    }
                    

                }
                //Console.Write(ary[i] + " ");
            }
            double avg = 0;

            for(int i = ary.Length-1;loop<i;i--)
            {
                avg = avg + ary[i];
            }
            avg = avg / loop;
            if(num/box==2)
            {
                Console.WriteLine(ary[0] - ary[num - 1]);
            }
            else
            {
                avg = ary[0] - avg;
                Console.WriteLine((int)avg);
            }
        }
    }
}
0