Type: RemoteJudge 1000ms 512MiB

[GESP202412 七级] 燃烧

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

小杨有一棵包含 nn 个节点的树,其中节点的编号从 11nn。节点 ii 的权值为 aia_i

小杨可以选择一个初始节点引燃,每个燃烧的节点会将其相邻节点中权值严格小于自身权值的在节点间扩散直到不会有新的节点被引燃。

小杨想知道在合理选择初始节点的情况下,最多可以燃烧多少个节点。

输入格式

第一行包含一个正整数 nn,表示节点数量。

第二行包含 nn 个正整数 a1,a2,,ana_1,a_2,\dots,a_n,代表节点权值。

之后 n1n-1 行,每行包含两个正整数 ui,viu_i,v_i,代表存在一条连接节点 uiu_iviv_i 的边。

输出格式

输出一个正整数,代表最多燃烧的节点个数。

5
6 2 3 4 5
1 2
2 3
2 5
1 4
3

提示

子任务编号 数据点占比 nn
11 20%20\% 10\leq 10
22 100\leq 100
33 60%60\% 105\leq 10^5

对于全部数据,保证有 1n1051\leq n\leq 10^51ai1061\leq a_i\leq 10^6

GESP七级

Not Claimed
Status
Done
Problem
16
Open Since
2025-8-15 0:00
Deadline
2025-8-27 23:59
Extension
24 hour(s)