結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
aaaaasatori
|
| 提出日時 | 2018-02-05 09:13:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 564 bytes |
| コンパイル時間 | 3,774 ms |
| コンパイル使用メモリ | 74,856 KB |
| 実行使用メモリ | 55,684 KB |
| 最終ジャッジ日時 | 2024-07-06 11:42:08 |
| 合計ジャッジ時間 | 12,990 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 28 WA * 10 |
ソースコード
import java.util.Scanner;
public class No275 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); // 整数の個数
int t[] = new int[n];
int x; //交換用
for(int i = 0;i < n;i++) {
t[i] = sc.nextInt();
}
for(int i = 0;i < n;i++) {
for(int j = i + 1;j < n;j++) {
if(t[i] > t[j]) {
x = t[i];
t[i] = t[j];
t[j] = x;
}
}
}
if(n % 2 == 1) {
System.out.println(t[n / 2]);
}else {
System.out.println((float)((t[n / 2] + t[n / 2 - 1]) / 2));
}
}
}
aaaaasatori