結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
piyoko_212
|
| 提出日時 | 2015-12-28 21:18:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 240 bytes |
| コンパイル時間 | 310 ms |
| コンパイル使用メモリ | 37,324 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 23:36:08 |
| 合計ジャッジ時間 | 1,293 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | int a;scanf("%d",&a);
| ~~~~~^~~~~~~~~
main.cpp:7:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | for(int i=0;i<a;i++)scanf("%d",b+i);
| ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[1100];
int main(){
int a;scanf("%d",&a);
for(int i=0;i<a;i++)scanf("%d",b+i);
std::sort(b,b+a);
if(a%2)printf("%d\n",b[a/2]);
else printf("%f\n",0.5*(b[a/2]+b[a/2-1]));
}
piyoko_212