結果
| 問題 | No.275 中央値を求めよ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-11 11:55:34 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 1,000 ms |
| コード長 | 841 bytes |
| 記録 | |
| コンパイル時間 | 3,940 ms |
| コンパイル使用メモリ | 82,948 KB |
| 実行使用メモリ | 45,472 KB |
| 最終ジャッジ日時 | 2026-03-11 03:43:48 |
| 合計ジャッジ時間 | 7,395 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class No0275 {
public static void main(String[] args) {
try (BufferedReader br =
new BufferedReader(new InputStreamReader(System.in))) {
int N = Integer.parseInt(br.readLine());
String[] str = br.readLine().split(" ");
int[] A = new int[N];
int length = A.length;
int l = length / 2;
for (int i = 0; i < N ; i++) {
A[i] = Integer.parseInt(str[i]);
}
Arrays.sort(A);
if(length % 2 == 0){
System.out.println( (double)(A[l - 1] + A[l]) / 2);
} else {
System.out.println(A[l]);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}