結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2020-05-02 16:13:28 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 325 bytes |
コンパイル時間 | 9,495 ms |
コンパイル使用メモリ | 259,744 KB |
最終ジャッジ日時 | 2025-01-10 05:56:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 28 WA * 10 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:6:18: warning: 'n' is used uninitialized [-Wuninitialized] 6 | vector<int> a(n); | ^ main.cpp:5:7: note: 'n' declared here 5 | int n, b, ans; | ^
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n, b, ans; vector<int> a(n); cin >> n; for (int i = 0; i < n; i++) { cin >> b; a.push_back(b); } sort(a.begin(), a.end()); if (n % 2 == 0) { cout << (a[n / 2 - 1] + a[n / 2]) / 2 << endl; } else { cout << a[n / 2] << endl; } }