結果
| 問題 | No.3660 LIS on Tree |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-08-30 15:10:29 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 709 bytes |
| 記録 | |
| コンパイル時間 | 247 ms |
| コンパイル使用メモリ | 96,112 KB |
| 実行使用メモリ | 125,848 KB |
| 最終ジャッジ日時 | 2026-08-30 15:11:10 |
| 合計ジャッジ時間 | 5,623 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 TLE * 1 -- * 11 |
ソースコード
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
N = int(input())
S = list(map(int, input().split()))
adj = defaultdict(list)
degs = [0] * N
for _ in range(N-1):
a, b = map(lambda x: int(x)-1, input().split())
adj[a].append(b)
adj[b].append(a)
degs[a] += 1
degs[b] += 1
def dfs(v):
s = S[v]
res = s
for to in adj[v]:
if S[to] >= s: continue
res = max(res, s + dfs(to))
return res
ans = 0
for i in range(N):
b = True
small = False
for to in adj[i]:
if S[to] > S[i]:
b = False
if S[to] < S[i]:
small = True
if b and small:
ans = max(ans, dfs(i))
print(ans)
norioc