結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2017-09-26 21:10:44 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 621 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 83,348 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 00:40:49 |
合計ジャッジ時間 | 2,037 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <cstring>#include <math.h>#include <cmath>#include <limits.h>#include <map>#include <set>#include <queue>#include <algorithm>#include <functional>#include <stdio.h>using namespace std;long long MOD = 1000000007;int main() {int N;cin >> N;vector<int> A(N);for ( int i = 0; i < N; i++ ) {cin >> A[i];}sort( A.begin(), A.end() );if ( N%2 ) { cout << A[N/2] << endl; }else { printf( "%f", ( static_cast<double>(A[N/2]) + static_cast<double>(A[(N-1)/2] ) ) / 2.0 ); }return 0;}