結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2024-06-02 08:32:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 611 bytes |
コンパイル時間 | 2,105 ms |
コンパイル使用メモリ | 173,004 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 03:41:29 |
合計ジャッジ時間 | 3,302 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ill = int long long;#define rep(i, n) for (ill i = 0; i < (n); i++)#define all(s) s.begin(), s.end()using inp = pair<int, int>;using vecb = vector<bool>;using vecb2 = vector<vecb>;int main(){int n;cin >> n;vector<double> a;rep(i, n){int s;cin >> s;a.push_back(s);}sort(all(a));if (n % 2 == 1){n = n / 2;cout << a[n] << endl;}else{n = n / 2;cout << fixed << setprecision(1);cout << (a[n - 1] + a[n]) / 2 << endl;}}