結果
| 問題 | No.3660 LIS on Tree |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-09-28 03:33:17 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,037 ms / 2,000 ms |
| + 510µs | |
| コード長 | 425 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 14,848 KB |
| 実行使用メモリ | 79,684 KB |
| 最終ジャッジ日時 | 2026-09-28 03:33:27 |
| 合計ジャッジ時間 | 9,509 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
import sys
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
E=[[] for i in range(N)]
for i in range(N-1):
x,y=list(map(int,input().split()))
x-=1
y-=1
E[x].append(y)
E[y].append(x)
XA=[(A[i],i) for i in range(N)]
XA.sort()
S=A[:]
for s,ind in XA:
now=S[ind]
for to in E[ind]:
if A[to]>A[ind]:
S[to]=max(S[to],A[to]+S[ind])
print(max(S))
titia