結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
![]() |
提出日時 | 2017-09-23 18:25:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 683 ms |
コンパイル使用メモリ | 78,872 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 04:15:40 |
合計ジャッジ時間 | 1,818 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 7 WA * 31 |
ソースコード
#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", (double)a[n / 2 + 1]); } else { printf("%.5lf\n", (double)((a[n / 2] + a[n / 2 + 1]) / 2)); } return 0; }