結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
|
提出日時 | 2019-09-05 20:49:57 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 531 bytes |
コンパイル時間 | 425 ms |
コンパイル使用メモリ | 31,104 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-13 01:15:16 |
合計ジャッジ時間 | 1,387 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 21 WA * 17 |
ソースコード
#include <stdio.h> #include <stdlib.h> #define swap(type,x,y) do{type t=x;x=y;y=t;}while(0) void bubble(int *x,int n) { int i,j; for(i=0;i<n-1;i++){ int exchg=0; for(j=n-1;j>i;j--) if(x[j-1]>x[j]){ swap(int,x[j-1],x[j]); exchg++; } if(exchg==0)break; } } int main(void){ int i,n; int *x; float f; scanf("%d",&n); x=calloc(n, sizeof(int)); for(i=0;i<n;i++){ scanf("%d",&x[i]); } bubble(x,n); if(n%2==0) f=(x[n/2]+x[n/2-1]); else f=x[n/2]; printf("%.1f\n",f/2); return 0; }