結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2021-06-06 17:15:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 399 bytes |
コンパイル時間 | 645 ms |
コンパイル使用メモリ | 75,516 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 00:31:50 |
合計ジャッジ時間 | 1,990 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> using namespace std; int main(){ int n; int a[1000]; cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; } sort(a, a + n); if(n % 2){ cout << a[n / 2] << endl; } else{ cout << fixed; cout << setprecision(1) << ((float)a[n / 2 - 1] + (float)a[n / 2]) / 2 << endl; } return 0; }