結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-15 00:16:14 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 183 ms / 1,000 ms |
| コード長 | 538 bytes |
| コンパイル時間 | 3,168 ms |
| コンパイル使用メモリ | 75,300 KB |
| 実行使用メモリ | 43,180 KB |
| 最終ジャッジ日時 | 2024-06-24 23:31:15 |
| 合計ジャッジ時間 | 10,641 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class No275 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] noList = new int[scanner.nextInt()];
for(int index = 0; index < noList.length; index++) {
noList[index] = scanner.nextInt();
}
Arrays.sort(noList);
if(noList.length % 2 == 1) {
System.out.println(noList[noList.length / 2]);
}
else {
System.out.println((noList[(noList.length / 2) - 1] + noList[noList.length / 2]) / 2.0);
}
scanner.close();
}
}