結果

問題 No.1188 レベルX門松列
ユーザー Example0911Example0911
提出日時 2020-08-23 11:17:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 1,291 bytes
コンパイル時間 1,404 ms
コンパイル使用メモリ 166,496 KB
実行使用メモリ 8,720 KB
最終ジャッジ日時 2024-04-23 17:31:02
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
8,720 KB
testcase_01 AC 37 ms
8,052 KB
testcase_02 AC 34 ms
7,860 KB
testcase_03 AC 45 ms
8,680 KB
testcase_04 AC 49 ms
8,688 KB
testcase_05 AC 2 ms
6,948 KB
testcase_06 AC 19 ms
8,688 KB
testcase_07 AC 42 ms
8,592 KB
testcase_08 AC 44 ms
8,696 KB
testcase_09 AC 2 ms
6,948 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 5 ms
6,944 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 6 ms
6,944 KB
testcase_14 AC 30 ms
7,252 KB
testcase_15 AC 45 ms
8,688 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 36 ms
8,008 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 33 ms
7,848 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

ll N;
ll A[100010], B[100010];

ll lLIS[100010], lLDS[100010], rLIS[100010], rLDS[100010];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	rep(i, N)cin >> A[i];
	rep(i, N)B[i] = -A[i];
	vector<ll>dp(N, INF);
	rep(i, N) {
		*lower_bound(dp.begin(), dp.end(), A[i]) = A[i];
		lLIS[i] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	}
	rep(i, N)dp[i] = INF;
	for (int i = N - 1; i >= 0; i--) {
		*lower_bound(dp.begin(), dp.end(), A[i]) = A[i];
		rLIS[i] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	}
	rep(i, N)dp[i] = INF;
	rep(i, N) {
		*lower_bound(dp.begin(), dp.end(), B[i]) = B[i];
		lLDS[i] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	}
	rep(i, N)dp[i] = INF;
	for (int i = N - 1; i >= 0; i--) {
		*lower_bound(dp.begin(), dp.end(), B[i]) = B[i];
		rLDS[i] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	}
	ll ans = 0;
	rep(i, N) {
		ans = max(ans, min(lLIS[i], rLIS[i]) - 1);
		ans = max(ans, min(lLDS[i], rLDS[i]) - 1);
	}
	cout << ans << endl;
	return 0;
}
0