結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
Kinoshita
|
| 提出日時 | 2015-09-06 13:27:46 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 189 ms / 1,000 ms |
| コード長 | 476 bytes |
| コンパイル時間 | 2,212 ms |
| コンパイル使用メモリ | 74,832 KB |
| 実行使用メモリ | 42,936 KB |
| 最終ジャッジ日時 | 2024-06-24 23:12:44 |
| 合計ジャッジ時間 | 9,972 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class Main{
static Main byakko = new Main();
static Scanner sc = new Scanner(System.in);
public static void main(String[] args){
int n = sc.nextInt();
double[] x = new double[n];
for(int i = 0; i < n; i++){
x[i] = sc.nextInt();
}
Arrays.sort(x);
if(n % 2 == 0){
System.out.println((x[n / 2] + x[n / 2 - 1]) / 2);
}
else{
System.out.println(x[n / 2]);
}
sc.close();
}
}
Kinoshita