結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2023-06-28 23:16:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 444 bytes |
コンパイル時間 | 681 ms |
コンパイル使用メモリ | 75,020 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-05 16:38:17 |
合計ジャッジ時間 | 1,734 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 }