結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2020-02-13 22:21:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 577 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 46,380 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-06 06:32:21 |
合計ジャッジ時間 | 1,475 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 23 WA * 15 |
ソースコード
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <algorithm> using namespace std; int main() { int answer; int n; scanf("%d", &n); int array[n]; for (int i = 0; i < n; i++) { int a; scanf("%d", &a); array[i] = a; } sort(array, array + sizeof(array) / sizeof(array[0])); if (n % 2 == 0) { int index1 = n / 2 - 1; int index2 = index1 + 1; printf("%.1f\n", (array[index1] + array[index2]) / 2.0); } else { printf("%d\n", array[n / 2 - 1]); } }