結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
Maeda
|
| 提出日時 | 2025-03-03 15:45:30 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 756 bytes |
| コンパイル時間 | 399 ms |
| コンパイル使用メモリ | 26,880 KB |
| 実行使用メモリ | 8,612 KB |
| 最終ジャッジ日時 | 2025-03-03 15:45:32 |
| 合計ジャッジ時間 | 1,782 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 RE * 10 |
ソースコード
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
void main(void){
int n = 0;
int inputN = scanf("%d\n",&n);
if(inputN == 2){
printf("nの入力ミス\n");
}
double median = 0;
int *numberList = (int *)malloc((size_t)n * sizeof(int));
for(int i = 0;i < n;i++){
int inputSum = scanf("%d",&numberList[i]);
if(inputSum == 2){
printf("Sumの入力ミス\n");
}
}
for(int i = 0 ; i < n ; i ++){
for(int j = 0 ; j < n ; j ++){
if(numberList[i] > numberList[j]){
int num = numberList[i];
numberList[i] = numberList[j];
numberList[j] = num;
}
}
}
if(n%2 != 0){
printf("%0.01f\n",(double)numberList[n/2]);
} else {
printf("%0.01f\n",(double)(numberList[n/2-1] + numberList[n/2]) /2);
}
free(numberList);
}
Maeda