結果

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const int INF = 1e9;

int main() {
	int n;

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

	int ans = INF;
	for (int i = 1; i < n; i++) {
		int diff = x[i] - x[i - 1];
		if (diff != 0) {
		ans = min(diff, ans);
		}
	}

	if (ans == INF) {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}
0