結果

問題 No.135 とりあえず1次元の問題
ユーザー a2011404
提出日時 2017-03-03 09:46:11
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 04:41:22
合計ジャッジ時間 1,603 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 1 WA * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:27:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 | scanf("%ld",&n);
      | ^~~~~~~~~~~~~~~
main.c:30:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         scanf("%ld",&x[i]);
      |         ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

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




int sortfnc(const void *a,const void *b){

	if(*(int*)a == *(int*)b){
	return 0;
	}

	if(*(int*)a < *(int*)b)
	{return -1;
	}

	return 1;

}


int main(void)
{

long int n,x[100000],i,c=1000001;

scanf("%ld",&n);

for(i=0;i<n;i++){
	scanf("%ld",&x[i]);
}
	qsort(x, n, sizeof(int), sortfnc);

if(n==1 || n==0){
	c=0;
}

for(i=0;i<n-1;i++){
	if( x[i] != x[i+1] && x[i+1]-x[i]<c){
		c=x[i+1]-x[i];
	}
	
}
if(c==1000001){
	c=0;
}

printf("%ld\n",c);





return 0;

}
0