結果

問題 No.135 とりあえず1次元の問題
ユーザー Kurichan0806
提出日時 2017-12-05 16:24:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 88,672 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-28 16:47:42
合計ジャッジ時間 2,214 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;
#define diff(x,y) ((x > y) ? (x - y) : (y - x))
#define us(x) (x > 0) ? x : x * -1
const int MAX = 100001;

int main() {
	long long int n, min = MAX;
	cin >> n;
	vector <long long int> x(n);
	for (int i = 0; i < n; i++)
		cin >> x[i];
	if (n < 2) {
		cout << 0 << endl;
		return 0;
	}
	sort(x.begin(), x.end());
	for (int i = 0; i < n - 1; i++) 
		if (x[i + 1] - x[i] < min && x[i + 1] != x[i])	min = x[i + 1] - x[i];
	if (min == MAX)	cout << 0 << endl;
	else			cout << min << endl;
	return 0;
}
0