結果
| 問題 | No.209 Longest Mountain Subsequence |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-02-25 23:10:47 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 754 bytes |
| 記録 | |
| コンパイル時間 | 1,559 ms |
| コンパイル使用メモリ | 20,952 KB |
| 実行使用メモリ | 25,148 KB |
| 最終ジャッジ日時 | 2026-02-25 23:11:01 |
| 合計ジャッジ時間 | 8,086 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 2 -- * 2 |
ソースコード
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