結果

問題 No.135 とりあえず1次元の問題
ユーザー KKT89
提出日時 2020-01-06 05:52:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 448 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 78,220 KB
最終ジャッジ日時 2025-01-08 16:26:04
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	if(n==1){
		cout << 0 << endl;
		return 0;
	}
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int ans=1e9;
	for(int i=0;i<n-1;i++){
		if(a[i+1]-a[i])ans=min(ans,a[i+1]-a[i]);
	}
	if(ans==1e9)ans=0;
	cout << ans << endl;
}
0