結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2017-07-04 14:40:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 654 bytes |
コンパイル時間 | 1,698 ms |
コンパイル使用メモリ | 168,800 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 00:34:27 |
合計ジャッジ時間 | 2,832 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;//--------------------------------------------#define FOR(i,a,b) for(int i=(a);i<(b);i++)#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)#define REP(i,n) FOR(i,0,n)#define RREP(i,n) RFOR(i,0,n)#define LL long long#define INF INT_MAX/3//--------------------------------------------const double EPS = 1e-14;const double PI = acos(-1.0);//--------------------------------------------int main(){int n;int a[1010];scanf("%d",&n);REP (i,n) scanf("%d",&a[i]);sort(a, a + n);if (n % 2 == 1) printf("%d\n",a[n / 2]);else printf("%.1lf\n",double(a[(n / 2) - 1] + a[n / 2]) / 2);}