結果

問題 No.135 とりあえず1次元の問題
ユーザー くれちー
提出日時 2016-08-26 12:56:05
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 06:55:22
合計ジャッジ時間 1,131 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:13:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%d", &x[i]);
      |                 ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int comp(const void *arg1, const void *arg2) {
	return *(int *)arg1 - *(int *)arg2;
}

int main() {
	int n, x[100000], d, min = 1000000, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}
	
	qsort(x, n, sizeof(int), comp);
	for (i = 1; i < n; i++) {
		d = x[i] - x[i - 1];
		if (d < min && d > 0) min = d;
	}

	printf("%d\n", min);
	return 0;
}
0