結果

問題 No.1188 レベルX門松列
ユーザー Example0911Example0911
提出日時 2020-08-23 11:09:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,327 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 168,948 KB
実行使用メモリ 8,820 KB
最終ジャッジ日時 2024-04-23 17:30:34
合計ジャッジ時間 3,071 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
8,704 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 19 ms
8,704 KB
testcase_07 AC 42 ms
8,676 KB
testcase_08 AC 42 ms
8,820 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 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;

// コンテスト中のみ
//#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];
	reverse(B, B + N);
	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[N - i - 1] = 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[N - i - 1] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	}
	ll ans = 0;
	rep(i, N) {
		ans = max(ans, min(lLDS[i], rLIS[i]) - 1);
		ans = max(ans, min(lLIS[i], rLDS[i]) - 1);
	}
	cout << ans << endl;
	return 0;
}
0