結果
| 問題 | No.1188 レベルX門松列 |
| コンテスト | |
| ユーザー |
onsen_manjuuu
|
| 提出日時 | 2020-09-01 01:27:30 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 777 bytes |
| 記録 | |
| コンパイル時間 | 1,729 ms |
| コンパイル使用メモリ | 172,152 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 03:02:58 |
| 合計ジャッジ時間 | 3,577 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 11 |
ソースコード
#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]);
*itr = a[i];
f[i] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}
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(min(frot[i-1], back[i+1]), nax);
}
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;
}
onsen_manjuuu