結果

問題 No.275 中央値を求めよ
ユーザー nyro2nyro2
提出日時 2017-12-05 13:20:19
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 465 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 51,816 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-19 03:22:44
合計ジャッジ時間 6,244 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 RE -
testcase_03 AC 1 ms
4,384 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 RE -
testcase_12 AC 1 ms
4,380 KB
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
testcase_25 WA -
testcase_26 RE -
testcase_27 WA -
testcase_28 RE -
testcase_29 WA -
testcase_30 RE -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

int main() {
    int N;
    float A[1000];
    int B[1000];
    
    std::cin >> N;
    
    for (int i=0; i<N; i++) {
        std::cin >> A[i];
    }
    
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            if (A[i] > A[j]) B[i] += 1;
        }
    }    
    
    if (N % 2 == 0) std::cout << ((A[B[N/2]] + A[B[N/2-1]]) / 2) << std::endl;
    else std::cout << A[B[N/2-1]] << std::endl;
	
	return 0;
}
0