結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,528 KB
testcase_01 AC 2 ms
5,424 KB
testcase_02 AC 2 ms
5,620 KB
testcase_03 AC 2 ms
5,452 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,408 KB
testcase_06 AC 14 ms
18,508 KB
testcase_07 AC 2 ms
5,768 KB
testcase_08 AC 2 ms
5,716 KB
testcase_09 AC 2 ms
5,508 KB
testcase_10 AC 3 ms
5,524 KB
testcase_11 AC 2 ms
6,068 KB
testcase_12 AC 67 ms
48,208 KB
testcase_13 AC 93 ms
56,504 KB
testcase_14 AC 77 ms
53,040 KB
testcase_15 AC 113 ms
64,216 KB
testcase_16 AC 75 ms
52,520 KB
testcase_17 AC 79 ms
56,808 KB
testcase_18 AC 69 ms
52,016 KB
testcase_19 AC 43 ms
39,896 KB
testcase_20 AC 43 ms
40,180 KB
testcase_21 AC 23 ms
28,044 KB
testcase_22 AC 113 ms
66,116 KB
testcase_23 AC 121 ms
66,008 KB
testcase_24 AC 85 ms
59,684 KB
testcase_25 AC 99 ms
64,352 KB
testcase_26 AC 59 ms
44,308 KB
権限があれば一括ダウンロードができます

ソースコード

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) rep(j, n) maxup(res, max(dp[0][i][j], dp[1][i][j]));

  cout << res << endl;

  return 0;
}
0