結果
問題 |
No.275 中央値を求めよ
|
ユーザー |
|
提出日時 | 2018-03-08 15:14:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 437 bytes |
コンパイル時間 | 1,486 ms |
コンパイル使用メモリ | 169,136 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 00:54:44 |
合計ジャッジ時間 | 2,591 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h> using namespace std; namespace { int A[ 1010 ]; } int main() { int i; int N; int x; cin >> N; for( i = 0; i < N; i++ ) cin >> A[ i ]; sort( A, A + N ); if( N % 2 == 1 ) cout << A[ N / 2 ] << endl; else { i = N / 2; x = A[ i - 1 ] + A[ i ]; if( x < 0 ) { cout << "-"; x *= - 1; } if( x % 2 == 1 ) cout << x / 2 << ".5" << endl; else cout << x / 2 << endl; } return 0; }