結果

問題 No.135 とりあえず1次元の問題
ユーザー mizuyoukannKBmizuyoukannKB
提出日時 2016-04-03 22:48:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 66,728 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 00:22:22
合計ジャッジ時間 6,588 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <vector>
#include <climits>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int num, val, ans = INT_MAX - 101;
	int lower, upper;
	vector<int> lst { INT_MIN + 100, INT_MAX - 100 };
	vector<int>::iterator itIn, itRef;

	cin >> num;

	while(num)
	{
		--num;

		cin >> val;
		itIn = find_if(lst.begin(), lst.end(), [=](int l){ return val < l; });
		itRef = lst.insert(itIn, val);

		lower = *(itRef + 0) - *(itRef - 1);
		upper = *(itRef + 1) - *(itRef + 0);

		if(lower == 0)
		{
			lst.erase(itRef);

			continue;
		}

		if(lower > 0)
		{
			ans = min(min(lower, upper), ans);
		}
	}

	cout << ans << endl;

	return 0;
}
0