結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2020-08-02 18:14:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 459 bytes |
コンパイル時間 | 1,521 ms |
コンパイル使用メモリ | 172,116 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 04:07:07 |
合計ジャッジ時間 | 2,595 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h> #define INF 2000000000000000000 #define ll long long #define pll pair<ll, ll> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; vector<ll> A(N); for (ll i = 0; i < N; ++i) { cin >> A.at(i); } sort(A.begin(), A.end()); double ans; if (N % 2 == 0) { ans = (A.at(N / 2 - 1) + A.at(N / 2)) / 2.0; } else { ans = A.at(N / 2); } cout << ans << "\n"; }