結果

問題 No.1188 レベルX門松列
ユーザー WarToksWarToks
提出日時 2020-08-22 15:32:00
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,373 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 112,000 KB
最終ジャッジ日時 2024-04-23 09:50:00
合計ジャッジ時間 1,473 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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

ソースコード

diff #

#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;
}
0