結果
| 問題 |
No.275 中央値を求めよ
|
| ユーザー |
ARCANA
|
| 提出日時 | 2023-06-28 23:17:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 444 bytes |
| コンパイル時間 | 635 ms |
| コンパイル使用メモリ | 75,848 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-05 16:39:45 |
| 合計ジャッジ時間 | 1,760 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
// input
int N;
cin >> N;
vector<int> A(N+1);
A.at(0)=0;
for(int i=1;i<=N;i++){
cin >> A.at(i);
}
sort(A.begin(),A.end());
float ans;
if(N % 2 == 1){
int center = (N+1)/2;
ans = A.at(center);
} else {
int center = N/2;
ans = (A.at(center) + A.at(center+1))/2.0;
}
cout << ans << endl;
// output
}
ARCANA