結果
問題 | No.21 平均の差 |
ユーザー | drymouse |
提出日時 | 2019-12-12 23:28:40 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 798 bytes |
コンパイル時間 | 2,345 ms |
コンパイル使用メモリ | 28,928 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-08 05:07:25 |
合計ジャッジ時間 | 1,134 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,384 KB |
testcase_02 | AC | 0 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,384 KB |
testcase_07 | AC | 0 ms
4,380 KB |
testcase_08 | AC | 0 ms
4,380 KB |
testcase_09 | AC | 0 ms
4,380 KB |
ソースコード
#include <stdio.h> #include <stdlib.h> #include <string.h> void sort(int *x, size_t s); void swap(int *x, int *y); int main(void) { int N, K; int n[10] = {0}; int sn = sizeof(n) / sizeof(n[0]); int *pn; pn = n; scanf("%d", &N); scanf("%d", &K); for (int i = 0; i < N; i++) { scanf("%d", &n[i]); } sort(pn, sn); printf("%d\n", n[N-1]-n[0]); return EXIT_SUCCESS; } void sort(int *x, size_t s) { for (int i = s; i > 1; i--) { for (int j = 1; j < i; j++) { if (*(x+j) == 0) { break; } else if (*(x+j-1) > *(x+j)) { swap(x+j-1, x+j); } } } return; } void swap(int *x, int *y) { int t; t = *x; *x = *y; *y = t; return; }