結果

問題 No.135 とりあえず1次元の問題
ユーザー toshiro_yanagi
提出日時 2019-01-07 22:02:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 413 bytes
コンパイル時間 816 ms
コンパイル使用メモリ 74,412 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 00:30:52
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 100100100;

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 = 0; i < n - 1; i++)
	{
		int a = X[i + 1], b = X[i];
		if (a != b)
		{
			ans = min(ans, a - b);
		}
	}
	cout << (ans != INF ? ans : 0) << endl;
}
0