結果
| 問題 |
No.21 平均の差
|
| ユーザー |
|
| 提出日時 | 2015-06-07 18:15:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 265 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 43,996 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 14:34:04 |
| 合計ジャッジ時間 | 867 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d", &k);
| ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int n, k;
vector<int> v;
scanf("%d %d", &n, &k);
for(int i=0; i<n; i++){
scanf("%d", &k);
v.push_back(k);
}
sort(v.begin(), v.end());
printf("%d\n", v[n-1]-v[0]);
}