結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2017-05-02 21:46:56 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 829 bytes |
コンパイル時間 | 2,203 ms |
コンパイル使用メモリ | 75,304 KB |
実行使用メモリ | 37,576 KB |
最終ジャッジ日時 | 2024-09-14 04:47:27 |
合計ジャッジ時間 | 5,629 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 23 WA * 14 RE * 1 |
ソースコード
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)-1]); } } }