結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2015-12-20 10:50:09 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 56 ms / 1,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 2,187 ms |
コンパイル使用メモリ | 76,096 KB |
実行使用メモリ | 50,640 KB |
最終ジャッジ日時 | 2024-06-24 23:35:19 |
合計ジャッジ時間 | 5,442 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import java.io.*;import java.util.*;class Main275 {public static void out (Object out) {System.out.println(out);}public static void main (String[] args) throws IOException {BufferedReader br =new BufferedReader(new InputStreamReader(System.in));int n = Integer.parseInt(br.readLine());int[] nums = new int[n];String[] str = br.readLine().split(" ");for (int i = 0; i < n; i++)nums[i] = Integer.parseInt(str[i]);Arrays.sort(nums);if (n % 2 == 0)out((nums[n / 2] + nums[n / 2 - 1]) / 2.0);elseout(nums[n / 2]);}}