結果

問題 No.609 Noelちゃんと星々
ユーザー mbanmban
提出日時 2018-01-09 19:56:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,682 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 105,016 KB
実行使用メモリ 38,680 KB
最終ジャッジ日時 2023-08-25 02:24:39
合計ジャッジ時間 5,916 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
29,004 KB
testcase_01 AC 87 ms
24,996 KB
testcase_02 AC 80 ms
23,208 KB
testcase_03 AC 89 ms
24,236 KB
testcase_04 AC 79 ms
23,120 KB
testcase_05 AC 123 ms
32,040 KB
testcase_06 AC 114 ms
29,492 KB
testcase_07 AC 93 ms
25,168 KB
testcase_08 AC 72 ms
22,716 KB
testcase_09 AC 85 ms
23,480 KB
testcase_10 AC 103 ms
27,596 KB
testcase_11 AC 101 ms
29,344 KB
testcase_12 AC 109 ms
26,684 KB
testcase_13 AC 76 ms
23,108 KB
testcase_14 AC 71 ms
22,440 KB
testcase_15 AC 113 ms
29,512 KB
testcase_16 AC 127 ms
38,380 KB
testcase_17 AC 110 ms
29,008 KB
testcase_18 AC 81 ms
23,344 KB
testcase_19 AC 112 ms
31,424 KB
testcase_20 AC 131 ms
38,608 KB
testcase_21 AC 130 ms
34,632 KB
testcase_22 AC 131 ms
36,704 KB
testcase_23 AC 131 ms
38,544 KB
testcase_24 AC 131 ms
38,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int N;
        private long[] Y;
        public void Solve()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            Y = sc.LongArray();
            Array.Sort(Y);
            Console.WriteLine(Calc(Y[N / 2]));
        }

        private long Calc(long t)
        {
            long ans = 0;
            foreach (long l in Y)
            {
                ans += Math.Abs(l - t);
            }
            return ans;
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}
0