結果

問題 No.275 中央値を求めよ
ユーザー IlagIlag
提出日時 2019-10-20 19:03:16
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 1,461 ms
コンパイル使用メモリ 160,624 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 17:29:16
合計ジャッジ時間 2,214 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];
    double ans = 0;
    if (n%2 == 0) {
        sort(A, A+n);
        int i = 1;
        for (; i < n/2; i++);
        int j = i-1;
        ans = (A[j]+A[i])/2.0;
    } else {
        double sum = 0;
        REP(i,n) sum += A[i];
        ans = sum/n;
    }
    cout << ans << endl;
}
0