結果
| 問題 | 
                            No.275 中央値を求めよ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-04-05 19:31:15 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 631 bytes | 
| コンパイル時間 | 781 ms | 
| コンパイル使用メモリ | 28,672 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-13 00:24:28 | 
| 合計ジャッジ時間 | 1,922 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 3 | 
| other | WA * 38 | 
ソースコード
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}
int main(void) {
    int len,arraylen;
    int array[1001];
    double answer;
    scanf("%d", &len);
    for(int count=0; count<=len; count++) {
        scanf("%d", &array[count]);
    }
    arraylen = sizeof array / sizeof array[0];
    printf("array length is %d", arraylen);
    qsort(array, arraylen, sizeof(int), compare_int);
    if(arraylen % 2 == 1) {
        printf("%d", array[arraylen/2+1]);
    } else {
        printf("%d", (array[arraylen/2] + array[arraylen/2+1])/2);
    }
    return 0;
}