結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-19 14:53:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 763 bytes |
| コンパイル時間 | 4,416 ms |
| コンパイル使用メモリ | 82,336 KB |
| 実行使用メモリ | 42,660 KB |
| 最終ジャッジ日時 | 2024-12-30 05:08:06 |
| 合計ジャッジ時間 | 13,946 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 28 WA * 10 |
ソースコード
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class CenterNum {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
ArrayList<Integer> list = new ArrayList();
for(int i=0;i<n;i++){
list.add(scanner.nextInt());
}
Collections.sort(list);
if(list.size() % 2 == 0){
float num = (list.get(list.size()/2 - 1) + list.get(list.size()/2)) / 2;
System.out.println(String.format("%.1f", num));
}else{
int num = list.get(list.size()/2);
System.out.println(num);
}
}
}