結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
takeya_okino
|
| 提出日時 | 2017-06-20 12:24:57 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 582 bytes |
| コンパイル時間 | 2,191 ms |
| コンパイル使用メモリ | 75,708 KB |
| 実行使用メモリ | 56,256 KB |
| 最終ジャッジ日時 | 2024-10-02 04:35:12 |
| 合計ジャッジ時間 | 10,465 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 26 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
ArrayList<Integer> num = new ArrayList<Integer>();
for(int i = 0; i < N; i++) {
int a = sc.nextInt();
if(!(num.contains(a))) {
num.add(a);
}
}
Collections.sort(num);
double ans = 0;
int si = num.size();
if(si % 2 == 0) {
ans = (double)(num.get(si / 2) + num.get(si / 2 - 1)) / (double)2;
} else {
ans = num.get(si / 2);
}
System.out.println(ans);
}
}
takeya_okino