結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2017-06-24 13:54:30 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 337 bytes |
コンパイル時間 | 299 ms |
コンパイル使用メモリ | 37,320 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 00:33:50 |
合計ジャッジ時間 | 1,374 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 4 | main(){ | ^~~~ main.cpp: In function ‘int main()’: main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&A[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h>#include<algorithm>using namespace std;main(){int N;int A[1024];scanf("%d",&N);for(int i = 0;i < N;i++){scanf("%d",&A[i]);}sort(A,A+N);double mid;if(N % 2 == 0){mid = (A[N/2-1] + A[N/2]) / 2.0;}else{mid = A[N/2];}printf("%lf\n",mid);}