結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2015-09-04 22:25:47 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 273 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 37,324 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 23:08:12 |
合計ジャッジ時間 | 1,450 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | int n;scanf("%d",&n);int a[1001];for(int i=0;i<n;i++)scanf("%d",&a[i]); | ~~~~~^~~~~~~~~ main.cpp:7:67: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | int n;scanf("%d",&n);int a[1001];for(int i=0;i<n;i++)scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>#include <algorithm>using namespace std;//namaega184int main(){int n;scanf("%d",&n);int a[1001];for(int i=0;i<n;i++)scanf("%d",&a[i]);sort(a,a+n);double ans;if(n%2)ans=a[n/2];else ans=(a[n/2-1]+a[n/2])/2.0;printf("%f\n",ans);return 0;}