結果
問題 | No.127 門松もどき |
ユーザー | tnakao0123 |
提出日時 | 2016-03-21 00:53:21 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,086 bytes |
コンパイル時間 | 590 ms |
コンパイル使用メモリ | 85,148 KB |
実行使用メモリ | 73,912 KB |
最終ジャッジ日時 | 2024-04-08 21:11:08 |
合計ジャッジ時間 | 2,644 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 45 ms
59,572 KB |
testcase_13 | AC | 66 ms
67,764 KB |
testcase_14 | AC | 60 ms
63,668 KB |
testcase_15 | AC | 79 ms
73,908 KB |
testcase_16 | AC | 53 ms
63,668 KB |
testcase_17 | AC | 65 ms
67,764 KB |
testcase_18 | AC | 52 ms
61,620 KB |
testcase_19 | AC | 37 ms
51,376 KB |
testcase_20 | AC | 33 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 | - |
ソースコード
/* -*- 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] = (as[l] >= as[r]) ? dpl[l][r - 1] : max(dpl[l][r - 1], dpr[l + 1][r] + 1); dpr[l][r] = (as[l] <= as[r]) ? dpr[l + 1][r] : max(dpr[l + 1][r], dpl[l][r - 1] + 1); } } printf("%d\n", max(dpl[0][n - 1], dpr[0][n - 1])); return 0; }