結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2017-06-20 12:23:48 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 582 bytes |
コンパイル時間 | 2,410 ms |
コンパイル使用メモリ | 75,352 KB |
実行使用メモリ | 42,540 KB |
最終ジャッジ日時 | 2024-10-02 04:33:23 |
合計ジャッジ時間 | 10,747 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 10 WA * 26 RE * 2 |
ソースコード
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); } }