結果
| 問題 | 
                            No.209 Longest Mountain Subsequence
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nanophoto12
                         | 
                    
| 提出日時 | 2016-01-06 23:58:09 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,839 bytes | 
| コンパイル時間 | 702 ms | 
| コンパイル使用メモリ | 84,076 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-19 12:25:49 | 
| 合計ジャッジ時間 | 1,439 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 6 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <limits>
using namespace std;
#define FOR(x,y) for(int x = 0;x < (y);x++)
#define LLI long long int
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define _L(x) cout<<(x)<<endl
int T,N,A[1010];
int L[101][101];
int R[101][101];
int Left(int left, int right)
{
    int& target = L[left][right];
    if(target >= 0)
    {
        return target;
    }
    target = 0;
    FOR(x, left)
    {
        if(A[x] < A[left] && A[left] - A[x] < A[right]-A[left])
        {
            target = max(target,Left(x, left) + 1);
        }
    }
    return target;
}
int Right(int left, int right)
{
    int& target = L[left][right];
    if(target >= 0)
    {
        return target;
    }
    target = 0;
    for(int x = right + 1;x < N;x++)
    {
        if(A[x] < A[right] && A[right] - A[x] < A[left]-A[right])
        {
            target = max(target,Right(right, x) + 1);
        }
    }
    return target;
}
int Calculate(int peakIndex)
{
    int left = 0;
    int right = 0;
    FOR(x, peakIndex)
    {
        if(A[x] < A[peakIndex])
        {
            left = max(left, Left(x,peakIndex) + 1);
        }
    }
    for(int x = peakIndex + 1;x < N;x++)
    {
        if(A[x] < A[peakIndex])
        {
            right = max(right, Right(peakIndex, x) + 1);
        }
    }
    return left + right + 1;
}
int main()
{
    cin>>N;
    FOR(i,N) cin>>A[i];
    FOR(i,101) FOR(j,101)
    {
        L[i][j] = -1;
        R[i][j] = -1;
    }
    
    int maxLength = -1;
    FOR(i, N)
    {
        maxLength = max(maxLength, Calculate(i));
    }
    cout << maxLength << endl;
    return 0;
}
            
            
            
        
            
nanophoto12