結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2020-12-24 00:30:40 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 87 ms / 1,000 ms |
コード長 | 573 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 79,432 KB |
実行使用メモリ | 38,856 KB |
最終ジャッジ日時 | 2024-09-21 16:38:17 |
合計ジャッジ時間 | 6,586 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.stream.Stream;public class Main {public static void main(String[] args) throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));//入力値読み込みint count = Integer.parseInt(br.readLine());int[] num = Stream.of(br.readLine().split(" ")).mapToInt(n -> Integer.parseInt(n)).sorted().toArray();int di = count / 2;System.out.println((count % 2 == 0) ? (num[di - 1] + num[di]) / 2.0 : num[di]);}}