結果

問題 No.127 門松もどき
ユーザー imgry22imgry22
提出日時 2015-01-21 19:05:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,362 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 144,500 KB
実行使用メモリ 66,092 KB
最終ジャッジ日時 2023-09-05 02:43:45
合計ジャッジ時間 4,174 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,480 KB
testcase_01 AC 2 ms
5,608 KB
testcase_02 AC 2 ms
5,420 KB
testcase_03 AC 2 ms
5,588 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,432 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,748 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,712 KB
testcase_10 AC 2 ms
5,664 KB
testcase_11 AC 3 ms
6,052 KB
testcase_12 AC 88 ms
48,328 KB
testcase_13 AC 116 ms
56,384 KB
testcase_14 AC 106 ms
52,976 KB
testcase_15 AC 142 ms
64,176 KB
testcase_16 AC 102 ms
52,536 KB
testcase_17 AC 113 ms
56,788 KB
testcase_18 AC 98 ms
51,952 KB
testcase_19 AC 61 ms
39,840 KB
testcase_20 AC 62 ms
40,136 KB
testcase_21 AC 31 ms
28,016 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int MAX_N = 3000;
int n;
int A[MAX_N];
int dp[2][MAX_N][MAX_N];
int res;

int main()
{
  cin >> n;
  rep(i, n) cin >> A[i];

  rep(d, n) rep(L, n){
    int R = L + d;
    if(R > n-1) break;

    if(L == R) dp[0][L][R] = dp[1][L][R] = 1;

    maxup(dp[0][L][R], dp[0][L][R-1]);
    maxup(dp[1][L][R], dp[1][L+1][R]);

    if(A[L] < A[R]) maxup(dp[0][L][R], dp[1][L+1][R]+1);
    if(A[L] > A[R]) maxup(dp[1][L][R], dp[0][L][R-1]+1);
  }

  rep(i, n) maxup(res, max(dp[0][0][i], dp[1][i][n-1]));

  cout << res << endl;

  return 0;
}
0