結果

問題 No.1188 レベルX門松列
ユーザー onsen_manjuuuonsen_manjuuu
提出日時 2020-09-01 01:41:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 1,668 ms
コンパイル使用メモリ 170,544 KB
実行使用メモリ 5,980 KB
最終ジャッジ日時 2024-04-28 11:46:16
合計ジャッジ時間 3,190 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
5,976 KB
testcase_01 AC 49 ms
5,456 KB
testcase_02 AC 45 ms
5,376 KB
testcase_03 AC 61 ms
5,932 KB
testcase_04 AC 54 ms
5,980 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 26 ms
5,976 KB
testcase_07 AC 52 ms
5,976 KB
testcase_08 AC 51 ms
5,976 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 40 ms
5,376 KB
testcase_15 AC 68 ms
5,968 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 54 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 51 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const int INF = 1e9;
int n;


vector<int> LIS(vector<int> a) {
	vector<int> dp(n, INF);
	vector<int> f(n);
	for(int i = 0; i < n; i++) {
		auto itr = lower_bound(dp.begin(), dp.end(), a[i]);
		f[i] = itr - dp.begin();
		*itr = a[i];
	}
	return f;

}

int f(vector<int> a, int cof) {
	for(auto &i: a) i *= cof;
	vector<int> frot = LIS(a);
	reverse(a.begin(), a.end());
	vector<int> back = LIS(a);
	reverse(back.begin(), back.end());

	int nax = 0;
	for(int i = 1; i < n - 1; i++) {
		nax = max(nax, min(frot[i], back[i]));
	}

	return nax;

}

int main()
{
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	cout << max(f(a, 1), f(a,-1)) << endl;
}
0