結果
| 問題 |
No.21 平均の差
|
| ユーザー |
chaba
|
| 提出日時 | 2017-04-17 13:25:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 450 bytes |
| コンパイル時間 | 110 ms |
| コンパイル使用メモリ | 23,040 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 05:22:08 |
| 合計ジャッジ時間 | 576 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:6:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d", &k);
| ~~~~~^~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d", &data[i]);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main (void) {
int n, k;
scanf("%d", &n);
scanf("%d", &k);
int data[n];
int i;
for (i = 0; i < n; i++) {
scanf("%d", &data[i]);
}
int tmp;
int j;
for (i = 0; i < n - 1; i++) {
for (j = n - 1; j > i; j--) {
if (data[j - 1] > data[j]) {
tmp = data[j];
data[j] = data[j - 1];
data[j - 1] = tmp;
}
}
}
int ans;
ans = data[n - 1] - data[0];
printf("%d\n", ans);
return 0;
}
chaba