結果
| 問題 |
No.127 門松もどき
|
| コンテスト | |
| ユーザー |
uenoku
|
| 提出日時 | 2017-01-08 00:34:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 977 bytes |
| コンパイル時間 | 702 ms |
| コンパイル使用メモリ | 80,396 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-17 17:13:09 |
| 合計ジャッジ時間 | 1,999 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 WA * 22 |
ソースコード
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
int main()
{
int n;
cin >> n;
int a[3004];
vector<pair<int, int>> p;
rep(i, n)
{
cin >> a[i];
p.push_back(make_pair(a[i], i));
}
sort(p.begin(), p.end());
int dp[3004][2] = {};
rep(i, n)
{
for (int j = p[i].second + 1; j < n; j++) {
if (a[j] > a[p[i].second])
dp[j][0] = max(dp[p[i].second][1] + 1, dp[j][0]);
}
for (int j = p[i].second - 1; j >= 0; j--) {
if (a[j] > a[p[i].second])
dp[j][1] = max(dp[p[i].second][0] + 1, dp[j][1]);
}
}
int ans = 0;
rep(i, n) rep(j, 2) ans = max(dp[i][j], ans);
cout << ans + 1 << endl;
}
uenoku