結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2016-07-22 18:34:11 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 1,249 ms |
コンパイル使用メモリ | 162,948 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 23:58:04 |
合計ジャッジ時間 | 2,285 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>#define REP(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))using namespace std;typedef int64_t ll;const int INF = 1e8;const double EPS = 1e-10;int main() {ios_base::sync_with_stdio(false);int N;cin >> N;vector<int> A(N);REP(i, 0, N) {cin >> A[i];}sort(A.begin(), A.end());if(N % 2 == 0) {int k = (N / 2) - 1;cout << 1.0*(A[k]+A[k+1])/2.00 << endl;} else {cout << A[N/2] << endl;}}