結果
問題 | No.127 門松もどき |
ユーザー | maine_honzuki |
提出日時 | 2020-05-18 17:11:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 908 bytes |
コンパイル時間 | 1,503 ms |
コンパイル使用メモリ | 163,436 KB |
実行使用メモリ | 74,520 KB |
最終ジャッジ日時 | 2024-04-09 21:30:40 |
合計ジャッジ時間 | 3,466 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 60 ms
56,096 KB |
testcase_13 | AC | 78 ms
63,344 KB |
testcase_14 | AC | 73 ms
60,568 KB |
testcase_15 | AC | 94 ms
71,488 KB |
testcase_16 | AC | 66 ms
59,812 KB |
testcase_17 | AC | 67 ms
65,280 KB |
testcase_18 | AC | 58 ms
59,032 KB |
testcase_19 | AC | 37 ms
46,100 KB |
testcase_20 | AC | 36 ms
47,116 KB |
testcase_21 | AC | 18 ms
32,880 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int N, A[3010]; int memo[3010][3010][2]; int len(int l, int r, int sign) { if (memo[l][r][sign] != -1) return memo[l][r][sign]; if (l == r) return 1; int tmp; if (sign) { if (A[l] > A[r]) { tmp = max(len(l, r - 1, !sign) + 1, len(l + 1, r, sign)); } else tmp = len(l + 1, r, sign); } else { if (A[l] < A[r]) { tmp = max(len(l + 1, r, !sign) + 1, len(l, r - 1, sign)); } else tmp = len(l, r - 1, sign); } return memo[l][r][sign] = tmp; } int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) for (int k = 0; k < 2; k++) memo[i][j][k] = -1; cout << max(len(0, N - 1, 0), len(0, N - 1, 1)) << endl; }