結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-06 22:49:18 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 1,000 ms |
| コード長 | 1,704 bytes |
| コンパイル時間 | 1,272 ms |
| コンパイル使用メモリ | 109,056 KB |
| 実行使用メモリ | 20,992 KB |
| 最終ジャッジ日時 | 2024-06-24 23:21:43 |
| 合計ジャッジ時間 | 4,128 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
int n = IO.R<int>();
double[] data = IO.R<double>(' ');
int c = data.Count();
Array.Sort(data);
IO.W(c % 2 == 0 ? (data[c / 2 - 1] + data[c / 2]) / 2 : data[c / 2]);
IO.WFLUSH();
}
}
namespace LIB
{
public class IO
{
private const int WMAX = 1000;
private static StringBuilder S = new StringBuilder();
public static T R<T>() { return UTIL.PARSE<T>(R()); }
public static T[] R<T>(char s = ' ') { return R().Split(s).Select(UTIL.PARSE<T>).ToArray(); }
public static T[] R<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R<T>(); } return r; }
public static T[][] R<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(s); } return r; }
private static string R() { return Console.ReadLine(); }
public static void W(object v, bool lf = true) { S.Append(UTIL.PARSE<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { WFLUSH(); } }
public static void WFLUSH() { Console.Write(S.ToString()); S.Clear(); }
}
public class UTIL
{
public static T PARSE<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
}
public class MEMO<Key, Result>
{
private Dictionary<Key, Result> R;
public MEMO() { R = new Dictionary<Key, Result>(); }
public Result EXEC(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
}
}