結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2019-02-27 13:43:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 666 bytes |
コンパイル時間 | 715 ms |
コンパイル使用メモリ | 79,260 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 05:08:00 |
合計ジャッジ時間 | 1,890 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> #include <vector> #define FOR(i, a, b) for (int i = a; i < b; i++) #define FORN(i, a, b) for (int i = a; i <= b; i++) #define P(s) cout << s << endl #define PC(condition, _true, _false) if (condition) _true; else _false; #define toInt(_char) _char - '0' using namespace std; // // Created by karayuu on 2019-02-26. // int main() { int n; cin >> n; vector<int> a(n); FOR(i, 0, n) { cin >> a[i]; } //ソート sort(a.begin(), a.end()); if (n % 2 == 0) { P((a[n / 2 - 1] + a[n / 2]) / 2.0); } else { P(a[(n - 1) / 2]); } }