結果

問題 No.1188 レベルX門松列
ユーザー cn_449cn_449
提出日時 2020-08-22 13:34:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,799 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 132,944 KB
実行使用メモリ 5,464 KB
最終ジャッジ日時 2023-08-05 10:36:40
合計ジャッジ時間 2,965 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
5,364 KB
testcase_01 AC 34 ms
4,904 KB
testcase_02 AC 31 ms
4,824 KB
testcase_03 AC 41 ms
5,368 KB
testcase_04 AC 33 ms
5,408 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 21 ms
5,388 KB
testcase_07 AC 33 ms
5,464 KB
testcase_08 AC 33 ms
5,388 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 26 ms
4,480 KB
testcase_15 AC 43 ms
5,364 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 33 ms
4,924 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 32 ms
4,876 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

int solve(vector<int> &a) {
	int n = a.size();
	vector<int> x(n), l(n, inf);
	rep(i, n) {
		int v = lower_bound(all(l), a[i]) - l.begin();
		x[i] = v;
		l[v] = a[i];
	}
	vector<int> rx(n), rl(n, inf);
	for (int i = n - 1; i >= 0; i--) {
		int v = lower_bound(all(rl), a[i]) - rl.begin();
		rx[i] = v;
		rl[v] = a[i];
	}
	int ans = 0;
	rep(i, n) chmax(ans, min(x[i], rx[i]));
	return ans;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> b(n);
	rep(i, n) b[i] = -a[i];
	cout << max(solve(a), solve(b)) << '\n';
}
0