結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2017-09-23 18:25:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 584 bytes |
コンパイル時間 | 697 ms |
コンパイル使用メモリ | 78,708 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 04:15:28 |
合計ジャッジ時間 | 1,987 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 4 WA * 34 |
ソースコード
#include<iostream> #include<string> #include<string.h> #include<algorithm> #include<stdio.h> #include<cmath> #include<vector> #include<utility> #include<queue> #include<stack> #include<stdlib.h> #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 using namespace std; int main(void) { int n; int a[1001]; cin >> n; FOR(i, 1, n) { cin >> a[i]; } sort(a, a + n + 1); if (n % 2 == 1) { printf("%.5lf\n", a[n / 2 + 1]); } else { printf("%.5lf\n", (double)((a[n / 2] + a[n / 2 + 1]) / 2)); } return 0; }