結果

問題 No.135 とりあえず1次元の問題
ユーザー keikei
提出日時 2016-08-15 20:40:25
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 64,368 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-11 06:52:58
合計ジャッジ時間 1,485 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> X(N, 0);
	vector<int> balance(N-1,0);
	for (int i = 0; i < N;i++) {
		cin >> X[i];
	}
	sort(X.begin(), X.end());
	for (int i = 1; i < N;i++) {
		if (X[i] == X[i - 1]) { balance[i - 1] = 9999999; }
		else {
			balance[i - 1] = X[i] - X[i - 1];
		}
	}
	sort(balance.begin(), balance.end());
	if (balance[0] == 9999999) {
		cout << 0 << endl;
	}
	else
	{
		cout << balance[0] << endl;
	}
	return 0;
}
0