結果
| 問題 | No.209 Longest Mountain Subsequence |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-02-25 23:09:58 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 754 bytes |
| 記録 | |
| コンパイル時間 | 2,649 ms |
| コンパイル使用メモリ | 77,828 KB |
| 実行使用メモリ | 180,404 KB |
| 最終ジャッジ日時 | 2026-02-25 23:10:19 |
| 合計ジャッジ時間 | 7,770 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge7 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 MLE * 5 |
ソースコード
def solve():
N = int(input())
A = list(map(int, input().split()))
def f(lis):
dp = {(lis[0], 0, 1)}
res = [1]
for a in lis[1:]:
pp = dp.copy()
dp, pp = pp, dp
max_cnt = 1
dp.add((a, 0, 1))
for x, d, cnt in pp:
if x < a and a-x > d:
nx = a
nd = a-x
ncnt = cnt+1
dp.add((nx, nd, ncnt))
max_cnt = max(max_cnt, ncnt)
res.append(max_cnt)
return res
lefts = f(A)
rights = f(A[::-1])[::-1]
return max([a+b-1 for a, b in zip(lefts, rights)])
T = int(input())
for t in range(T):
ans = solve()
print(ans)
norioc