結果

問題 No.275 中央値を求めよ
ユーザー KuraKura
提出日時 2019-09-23 12:50:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 36 ms / 1,000 ms
コード長 3,196 bytes
コンパイル時間 924 ms
コンパイル使用メモリ 110,696 KB
実行使用メモリ 25,328 KB
最終ジャッジ日時 2023-10-19 08:06:32
合計ジャッジ時間 4,077 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
25,040 KB
testcase_01 AC 29 ms
25,040 KB
testcase_02 AC 30 ms
25,048 KB
testcase_03 AC 28 ms
24,152 KB
testcase_04 AC 29 ms
25,044 KB
testcase_05 AC 29 ms
25,044 KB
testcase_06 AC 29 ms
25,048 KB
testcase_07 AC 35 ms
25,328 KB
testcase_08 AC 32 ms
24,496 KB
testcase_09 AC 33 ms
24,492 KB
testcase_10 AC 35 ms
25,324 KB
testcase_11 AC 26 ms
24,036 KB
testcase_12 AC 28 ms
24,228 KB
testcase_13 AC 28 ms
24,152 KB
testcase_14 AC 28 ms
24,220 KB
testcase_15 AC 35 ms
25,316 KB
testcase_16 AC 35 ms
25,316 KB
testcase_17 AC 34 ms
25,316 KB
testcase_18 AC 35 ms
25,320 KB
testcase_19 AC 33 ms
24,500 KB
testcase_20 AC 34 ms
25,328 KB
testcase_21 AC 35 ms
25,320 KB
testcase_22 AC 36 ms
25,328 KB
testcase_23 AC 33 ms
24,496 KB
testcase_24 AC 34 ms
25,320 KB
testcase_25 AC 35 ms
25,316 KB
testcase_26 AC 33 ms
24,500 KB
testcase_27 AC 32 ms
24,504 KB
testcase_28 AC 27 ms
24,152 KB
testcase_29 AC 32 ms
24,496 KB
testcase_30 AC 28 ms
24,152 KB
testcase_31 AC 35 ms
25,328 KB
testcase_32 AC 32 ms
24,492 KB
testcase_33 AC 33 ms
24,500 KB
testcase_34 AC 28 ms
24,148 KB
testcase_35 AC 32 ms
24,504 KB
testcase_36 AC 33 ms
24,496 KB
testcase_37 AC 35 ms
25,324 KB
testcase_38 AC 34 ms
25,320 KB
testcase_39 AC 33 ms
24,496 KB
testcase_40 AC 33 ms
24,500 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
class Start
{
    static void Main()
    {
        long n;Inl(out n);
        long[] a = new long[n];Inl(ref a);
        Sort(ref a);
        if (n % 2 == 0) Outl((a[n / 2 - 1] + a[n / 2]) / 2.0, 1);
        else Outl(a[n / 2]);
    }

    static void Inl(out long t) { t = long.Parse(Console.ReadLine()); }
    static void Inl(out string t) { t = Console.ReadLine(); }
    static void Inl(out char t) { t = Console.ReadLine()[0]; }
    static void Inl(out double t) { t = double.Parse(Console.ReadLine()); }
    static void Inl<T>(ref T[] t)
    {
        string[] s = Console.ReadLine().Split();
        Type type = typeof(T);
        int n = s.Length;
        if (type == LONG) for (int i = 0; i < n; i++) t[i] = (T)(object)long.Parse(s[i]);
        else if (type == STRING) for (int i = 0; i < n; i++) t[i] = (T)(object)s[i];
        else if (type == CHAR) for (int i = 0; i < n; i++) t[i] = (T)(object)s[i][0];
        else for (int i = 0; i < n; i++) t[i] = (T)(object)double.Parse(s[i]);
    }
    static void Inl<T, U>(out T t, out U u) { string[] s = Console.ReadLine().Split(); In(out t, ref s, 0); In(out u, ref s, 1); }
    static void Inl<T, U, V>(out T t, out U u, out V v) { string[] s = Console.ReadLine().Split(); In(out t, ref s, 0); In(out u, ref s, 1); In(out v, ref s, 2); }
    static void Inl<T, U, V, W>(out T t, out U u, out V v, out W w) { string[] s = Console.ReadLine().Split(); In(out t, ref s, 0); In(out u, ref s, 1); In(out v, ref s, 2); In(out w, ref s, 3); }
    static void Inl<T, U, V, W, X>(out T t, out U u, out V v, out W w, out X x) { string[] s = Console.ReadLine().Split(); In(out t, ref s, 0); In(out u, ref s, 1); In(out v, ref s, 2); In(out w, ref s, 3); In(out x, ref s, 4); }
    static void Inl<T, U, V, W, X, Y>(out T t, out U u, out V v, out W w, out X x, out Y y) { string[] s = Console.ReadLine().Split(); In(out t, ref s, 0); In(out u, ref s, 1); In(out v, ref s, 2); In(out w, ref s, 3); In(out x, ref s, 4); In(out y, ref s, 5); }
    static void Inl<T, U, V, W, X, Y, Z>(out T t, out U u, out V v, out W w, out X x, out Y y, out Z z) { string[] s = Console.ReadLine().Split(); In(out t, ref s, 0); In(out u, ref s, 1); In(out v, ref s, 2); In(out w, ref s, 3); In(out x, ref s, 4); In(out y, ref s, 5); In(out z, ref s, 6); }
    static void In<T>(out T t, ref string[] s, int i)
    {
        Type type = typeof(T);
        if (type == LONG) t = (T)(object)long.Parse(s[i]);
        else if (type == STRING) t = (T)(object)s[i];
        else if (type == CHAR) t = (T)(object)s[i][0];
        else t = (T)(object)double.Parse(s[i]);
    }
    static Type LONG = typeof(long);
    static Type STRING = typeof(string);
    static Type CHAR = typeof(char);

    static void Out<T>(T t) { Console.Write(t); }
    static void Outl<T>(T t) { Console.WriteLine(t); }
    static void Out(double d, int n) { string s = d.ToString("F" + n); Console.Write(s); }
    static void Outl(double d, int n) { string s = d.ToString("F" + n); Console.WriteLine(s); }

    static void Swap<T>(ref T a, ref T b) { T c = a; a = b; b = c; }
    static void Sort<T>(ref T[] t) { Array.Sort(t); }
}
0