結果

問題 No.127 門松もどき
ユーザー tnakao0123tnakao0123
提出日時 2016-03-21 01:01:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,166 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 85,144 KB
実行使用メモリ 73,912 KB
最終ジャッジ日時 2024-04-08 21:11:17
合計ジャッジ時間 2,385 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 AC 3 ms
10,028 KB
testcase_08 WA -
testcase_09 AC 2 ms
7,868 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
10,028 KB
testcase_12 AC 50 ms
59,572 KB
testcase_13 AC 69 ms
67,764 KB
testcase_14 AC 61 ms
63,668 KB
testcase_15 AC 86 ms
73,908 KB
testcase_16 AC 62 ms
63,668 KB
testcase_17 AC 67 ms
67,764 KB
testcase_18 AC 55 ms
61,620 KB
testcase_19 AC 35 ms
51,376 KB
testcase_20 AC 38 ms
51,376 KB
testcase_21 AC 17 ms
34,864 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 127.cc: No.127 門松もどき - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 3000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N];
int dpl[MAX_N][MAX_N], dpr[MAX_N][MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> as[i];

  for (int i = 0; i < n; i++) dpl[i][i] = dpr[i][i] = 1;

  for (int k = 1; k < n; k++) {
    for (int l = 0, r = k; r < n; l++, r++) {
      dpl[l][r] = dpl[l][r - 1];
      if (as[l] < as[r]) {
	int dr = dpr[l + 1][r] + 1;
	if (dpl[l][r] < dr) dpl[l][r] = dr;
      }
      dpr[l][r] = dpr[l + 1][r];
      if (as[l] > as[r]) {
	int dl = dpl[l][r - 1] + 1;
	if (dpr[l][r] < dl) dpr[l][r] = dl;
      }
    }
  }

  printf("%d\n", max(dpl[0][n - 1], dpr[0][n - 1]));
  return 0;
}
0