結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2019-09-03 17:15:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 1,789 ms |
コンパイル使用メモリ | 170,836 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 07:06:21 |
合計ジャッジ時間 | 3,289 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
/**@file 275.cpp@title No.275 中央値を求めよ - yukicoder@url https://yukicoder.me/problems/no/275**/#include <bits/stdc++.h>using namespace std;typedef long long LL;#define ALL(obj) (obj).begin(), (obj).end()#define REP(i, N) for (int i = 0; i < (N); ++i)int main() {int N;cin >> N;vector<int> A(N, 0);REP(i, N) { cin >> A[i]; }sort(ALL(A));if (N % 2 == 0) {cout << ((double)A[(N / 2) - 1] + (double)A[N / 2]) / 2.0 << endl;} else {cout << (double)A[N / 2] << endl;}return 0;}