結果

問題 No.135 とりあえず1次元の問題
ユーザー HaarHaar
提出日時 2016-04-15 02:29:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 434 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 58,780 KB
実行使用メモリ 7,024 KB
最終ジャッジ日時 2023-09-02 00:22:53
合計ジャッジ時間 1,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
6,880 KB
testcase_01 AC 5 ms
6,952 KB
testcase_02 AC 5 ms
6,712 KB
testcase_03 AC 5 ms
6,892 KB
testcase_04 AC 5 ms
6,948 KB
testcase_05 AC 5 ms
6,896 KB
testcase_06 AC 5 ms
6,912 KB
testcase_07 AC 5 ms
6,896 KB
testcase_08 AC 5 ms
6,832 KB
testcase_09 AC 5 ms
6,720 KB
testcase_10 AC 5 ms
6,948 KB
testcase_11 AC 5 ms
6,712 KB
testcase_12 AC 6 ms
6,880 KB
testcase_13 AC 5 ms
7,016 KB
testcase_14 AC 5 ms
6,952 KB
testcase_15 AC 5 ms
6,720 KB
testcase_16 AC 6 ms
6,836 KB
testcase_17 AC 5 ms
6,764 KB
testcase_18 AC 5 ms
7,024 KB
testcase_19 AC 6 ms
6,888 KB
testcase_20 AC 6 ms
6,908 KB
testcase_21 AC 36 ms
6,940 KB
testcase_22 AC 39 ms
6,720 KB
evil01.txt AC 36 ms
6,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n, x, min, temp;
	vector< int > table(1000001, 0);
	
	cin >> n;
	for(int i=0;i<n;++i){
		cin >> x;
		table[x] = 1;
	}
	
	temp = -1;
	min = -1;
	for(int i=0;i<=1000000;++i){
		if(table[i]){
			if(temp != -1){
				if(min == -1 || min > i - temp){
					min = i - temp;
				}
			}
			temp = i;
		}
	}
	if(min == -1)min = 0;
	cout << min << endl;
	
	return 0;
}
0