結果

問題 No.135 とりあえず1次元の問題
ユーザー ottyajp
提出日時 2015-05-09 10:05:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 63,612 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-03 05:48:42
合計ジャッジ時間 1,762 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin>>n;
	int x[n];
	int absv = 1000000;
	int abst;
	int t = 0;

	for (int i = 0; i < n ; ++i)
	{
		cin>>x[i];
	}
	sort(x, x+n);

	for (int i = 0; i < n-1; ++i)
	{
		abst=abs(x[i]-x[i+1]);
		if(absv == 1){
			cout<<"1"<<endl;
			return 0;
		}
		if( abst <= absv ){
			if(abst != 0){
				absv = abst;
				t = 1;
			}
		}
	}
	if(t == 0){
		cout<<"0"<<endl;
		return 0;
	}
	cout<<absv<<endl;

}
0