結果

問題 No.135 とりあえず1次元の問題
ユーザー dgd1724dgd1724
提出日時 2016-09-21 20:15:36
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,169 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 93,704 KB
実行使用メモリ 8,172 KB
最終ジャッジ日時 2023-09-02 00:35:21
合計ジャッジ時間 13,451 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
evil01.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES	//M_PI
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string
#include <vector>			//std::vector
#include <valarray>			//std::valarray	数値のみの一次配列
#include <algorithm>		//std::sort
#include <time.h>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs, std::pow, sqrt, sin, cos,
#include <fstream>			//std::ifstream
#include <iomanip>			//std::setprecision
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate

int main(void) {

	//test用
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	int N;
	std::cin >> N;
	std::vector<int> X(N);
	for (int i = 0; i < N; i++) {
		std::cin >> X[i];
	}

	int min = 0;
	bool flg = true;
	
	if (N == 1) {
		flg = false;
	}

	if (flg) {
		flg = false;
		for (int i = 0; i < N; i++) {
			if (X[0] != X[i]) {
				flg = true;
			}
		}
	}

	if (flg) {
		min = 1000000;
		int temp = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				if (X[i] != X[j]) {
					temp = abs(X[i] - X[j]);
					if (temp <= min) {
						min = temp;
					}
				}
			}
		}
	}

	std::cout << min << std::endl;
}


0