結果
| 問題 |
No.127 門松もどき
|
| コンテスト | |
| ユーザー |
otsnsk
|
| 提出日時 | 2015-01-16 21:19:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,252 bytes |
| コンパイル時間 | 544 ms |
| コンパイル使用メモリ | 65,164 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-22 12:05:38 |
| 合計ジャッジ時間 | 1,504 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 WA * 19 |
ソースコード
#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;
}
otsnsk