結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long> data(n);
	long long ans = LLONG_MAX;
	for(auto &a:data) cin >> a;
	sort(data.begin(),data.end());
	data.erase(unique(data.begin(),data.end()),data.end());
	for(int i = 0; i < n - 1; i++){
		int j = i + 1;
		if(data[i] == data[j]) continue;
		else ans = min(ans,abs(data[i] - data[j]));
	}
	cout << (ans == LLONG_MAX ? 0 : ans) << endl;
	return 0;
}
0