結果

問題 No.127 門松もどき
ユーザー otsnskotsnsk
提出日時 2015-01-16 21:19:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,252 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 65,604 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-04 13:39:01
合計ジャッジ時間 1,729 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
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 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};

using namespace std;

const int INF = 1e6;

int N;
vector<int> A(3010);

int check() {
    vector<int> h;
    h.reserve(N);

    int l = 0, r = N-1;
    for (; l <= r; ++l) {
        auto p = lower_bound(h.begin(), h.end(), A[l]);
        if (p == h.end()) {
            h.push_back(A[l]);
        }
        else {
            *p = A[l];
            continue;
        }
        for (; r >= l; --r) {
            p = lower_bound(h.begin(), h.end(), A[r]);
            if (p == h.end()) {
                h.push_back(A[r]);
                r--;
                break;
            }
            *p = A[r];
        }
    }
    return h.size();
}

int main() {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    cin >> N;
    FOR(i, N) cin >> A[i];

    int a1 = check();
    reverse(A.begin(), A.begin()+N);
    int a2 = check();
    cout << max(a1, a2) << endl;

    return 0;
}
0