結果

問題 No.275 中央値を求めよ
ユーザー neeet
提出日時 2017-06-15 03:00:26
言語 C
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 408 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 15,424 KB
最終ジャッジ日時 2024-09-24 23:34:12
合計ジャッジ時間 4,621 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(void)
{
  int n, i, j, cnt = 0;

  scanf("%d", &n);
  int w[n], sort[n];
  for(i = 0; i < n; i++)
    scanf("%d", &w[i]);
  for(i = 0; cnt < n; i++){
    for(j = 0; j < n; j++){
      if(w[j] == i){
        sort[cnt] = i;
        cnt++;
      }
    }
  }
  if(n & 1)
    printf("%f\n", (float)sort[n / 2]);
  else
    printf("%f\n", (float)(sort[n / 2] + sort[n / 2 - 1]) / 2);
}
0