結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
Kinoshita
|
| 提出日時 | 2015-09-05 14:00:14 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 546 bytes |
| コンパイル時間 | 2,000 ms |
| コンパイル使用メモリ | 74,308 KB |
| 実行使用メモリ | 42,592 KB |
| 最終ジャッジ日時 | 2024-07-19 03:48:36 |
| 合計ジャッジ時間 | 9,803 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 15 |
ソースコード
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
public class Main{
static Main byakko = new Main();
static Scanner sc = new Scanner(System.in);
static double[] x;
public static void main(String[] args)throws IOException{
int n = sc.nextInt();
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 - 1] + x[n / 2]) / 2);
}else if(n % 3 == 0){
System.out.println((int)(x[n / 2]));
}
sc.close();
}
}
Kinoshita