結果
| 問題 |
No.1188 レベルX門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 15:32:00 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,373 bytes |
| コンパイル時間 | 1,769 ms |
| コンパイル使用メモリ | 113,664 KB |
| 最終ジャッジ日時 | 2024-11-14 23:33:49 |
| 合計ジャッジ時間 | 2,267 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:11:39: error: no member named 'numeric_limits' in namespace 'std'
11 | std::vector<int> LiSA(n + 1, std::numeric_limits<int>::max());
| ~~~~~^
main.cpp:11:57: error: expected '(' for function-style cast or type construction
11 | std::vector<int> LiSA(n + 1, std::numeric_limits<int>::max());
| ~~~^
main.cpp:11:60: error: no member named 'max' in the global namespace
11 | std::vector<int> LiSA(n + 1, std::numeric_limits<int>::max());
| ~~^
main.cpp:12:20: error: no member named 'numeric_limits' in namespace 'std'
12 | LiSA[0] = std::numeric_limits<int>::min();
| ~~~~~^
main.cpp:12:38: error: expected '(' for function-style cast or type construction
12 | LiSA[0] = std::numeric_limits<int>::min();
| ~~~^
main.cpp:12:41: error: no member named 'min' in the global namespace
12 | LiSA[0] = std::numeric_limits<int>::min();
| ~~^
main.cpp:19:46: error: no member named 'numeric_limits' in namespace 'std'
19 | std::fill(LiSA.begin(), LiSA.end(), std::numeric_limits<int>::max());
| ~~~~~^
main.cpp:19:64: error: expected '(' for function-style cast or type construction
19 | std::fill(LiSA.begin(), LiSA.end(), std::numeric_limits<int>::max());
| ~~~^
main.cpp:19:67: error: no member named 'max' in the global namespace
19 | std::fill(LiSA.begin(), LiSA.end(), std::numeric_limits<int>::max());
| ~~^
main.cpp:20:20: error: no member named 'numeric_limits' in namespace 'std'
20 | LiSA[0] = std::numeric_limits<int>::min();
| ~~~~~^
main.cpp:20
ソースコード
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
int solve(const std::vector<int>& A){
const int n = A.size();
std::vector<int> LiSA(n + 1, std::numeric_limits<int>::max());
LiSA[0] = std::numeric_limits<int>::min();
std::vector<int> FrontLis(n);
for(int i = 0; i < n; ++i){
const int idx = std::lower_bound(LiSA.cbegin(), LiSA.cend(), A[i]) - LiSA.cbegin();
LiSA[idx] = A[i];
FrontLis[i] = idx;
}
std::fill(LiSA.begin(), LiSA.end(), std::numeric_limits<int>::max());
LiSA[0] = std::numeric_limits<int>::min();
int res = 0;
for(int i = n - 1; i >= 0; --i){
const int idx = std::lower_bound(LiSA.cbegin(), LiSA.cend(), A[i]) - LiSA.cbegin();
LiSA[idx] = A[i];
const int v = ((idx < FrontLis[i]) ? idx : FrontLis[i]) - 1;
if(res < v) res = v;
}
return res;
}
int main(void){
std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(16);
int n; std::cin >> n;
std::vector<int> A(n); for(int i = 0; i < n; ++i) std::cin >> A[i];
const int res1 = solve(A);
for(int i = 0; i < n; ++i) A[i] = -A[i];
const int res2 = solve(A);
std::cout << ((res1 < res2) ? res2 : res1) << '\n';
return 0;
}