結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2019-05-13 19:55:23 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 1,000 ms |
コード長 | 487 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 57,952 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 01:42:19 |
合計ジャッジ時間 | 1,692 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
//neko.cpp#include<iostream>#include<string>#include<math.h>using namespace std;int main(){int n;cin >> n;float a[1000];float kara[1];for (int i = 0; i <= n - 1; i++) {cin >> a[i];}for (int j = 0; j <= n - 1; j++) {for (int k = j; k <= n - 1; k++) {if (a[j] > a[k]) {kara[0] = a[j];a[j] = a[k];a[k] = kara[0];}}}if (n % 2 == 1) {cout << a[n / 2];}else if (n % 2 == 0) {cout << (a[n / 2 - 1] + a[n / 2]) / 2;}}