結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
aaaaasatori
|
| 提出日時 | 2018-02-05 09:16:14 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 197 ms / 1,000 ms |
| コード長 | 565 bytes |
| コンパイル時間 | 3,100 ms |
| コンパイル使用メモリ | 74,472 KB |
| 実行使用メモリ | 43,120 KB |
| 最終ジャッジ日時 | 2024-06-25 00:50:16 |
| 合計ジャッジ時間 | 10,592 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
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