結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2017-12-05 14:17:14 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 1,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 500 ms |
コンパイル使用メモリ | 54,752 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 00:43:59 |
合計ジャッジ時間 | 1,546 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream>int main() {int N;float A[1000];int B[1000] = { 0 };float C[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;} else if (A[i] == A[j]) {if (i > j) B[i] += 1;}}}for (int i=0; i<N; i++) {C[B[i]] = A[i];}if (N % 2 == 0) std::cout << ((C[N/2] + C[N/2-1]) / 2) << std::endl;else std::cout << C[N/2] << std::endl;return 0;}