cf/mirror

Tree with Maximum Cost

CF
1092F1900· candidate master2s256 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
8
9 4 1 7 10 1 6 5
1 2
2 3
1 4
1 5
5 6
5 7
5 8
Output
121
Sample 2of 2
Input
1
1337
Output
0
1092F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…