結果
| 問題 | No.3660 LIS on Tree |
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2026-08-30 14:06:04 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 589 bytes |
| 記録 | |
| コンパイル時間 | 408 ms |
| コンパイル使用メモリ | 95,600 KB |
| 実行使用メモリ | 151,936 KB |
| 最終ジャッジ日時 | 2026-08-30 14:06:49 |
| 合計ジャッジ時間 | 5,628 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 TLE * 1 -- * 11 |
ソースコード
import pypyjit
pypyjit.set_param("max_unroll_recursion=-1")
import sys
sys.setrecursionlimit(2*10**5+100)
from functools import cache
N = int(input())
S = list(map(int,input().split()))
edge = [[] for _ in range(N)]
for _ in range(N-1):
a,b = list(map(int,input().split()))
a -= 1;b -= 1
edge[a].append(b)
edge[b].append(a)
@cache
def dfs(n,pre):
ret = S[n]
for i in edge[n]:
if(i == pre):continue
if(S[n] >= S[i]):continue
ret = max(ret, dfs(i,n) + S[n])
return ret
ans = 0
for i in range(N):
ans = max(ans,dfs(i,-1))
print(ans)
回転