結果

問題 No.135 とりあえず1次元の問題
ユーザー a2011404
提出日時 2017-03-03 09:36:35
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 22,016 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 04:40:25
合計ジャッジ時間 880 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
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("%d",&n);
      | ^~~~~~~~~~~~~~
main.c:30:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         scanf("%d",&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)
{

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

scanf("%d",&n);

for(i=0;i<n;i++){
	scanf("%d",&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("%d\n",c);





return 0;

}
0