結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
fkwnw3_1243
|
| 提出日時 | 2017-05-02 21:47:53 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 1,000 ms |
| コード長 | 828 bytes |
| コンパイル時間 | 2,059 ms |
| コンパイル使用メモリ | 74,828 KB |
| 実行使用メモリ | 37,216 KB |
| 最終ジャッジ日時 | 2024-06-25 00:29:31 |
| 合計ジャッジ時間 | 5,249 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import static java.lang.System.in;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
int N = Integer.parseInt(reader.readLine());
int[] table = new int[N];
String[] inputs = reader.readLine().split(" ");
for (int i = 0; i < N; i++) {
table[i] = Integer.parseInt(inputs[i]);
}
Arrays.sort(table);
if (N % 2 == 0) {
int left = table[(N/2)-1];
int right = table[(N/2)];
System.out.println((left + right) / 2.0);
} else {
System.out.println(table[(N/2)]);
}
}
}
fkwnw3_1243