結果
問題 | No.21 平均の差 |
ユーザー |
![]() |
提出日時 | 2016-11-30 22:02:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 442 bytes |
コンパイル時間 | 120 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-27 14:05:04 |
合計ジャッジ時間 | 660 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%d %d",&n,&k); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",num+i); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h> int main(){ int n,k; scanf("%d %d",&n,&k); int num[n],i; for(i=0;i<n;i++){ scanf("%d",num+i); } int temp,j; //sort for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(num[j]<num[i]){ temp = num[j]; num[j] = num[i]; num[i] = temp; } } } //最大値と最小値をそれぞれ一つだけのグループに分けた差が、平均の差の最大値 printf("%d",num[n-1]-num[0]); return 0; }