HDU 5834 Magic boy Bi Luo with his excited tree__hdu

Source: Internet
Author: User


Problem Description Bi Luo is a magic boy, him also has a migic tree, the tree has N nodes, at each node, there is a Tre Asure, it ' s value is v[i], with for each edge, there be a cost c[i], which means, every Ed to pay C[i].

You could attention that every v[i] can is taken only once, but for some c[i], your may cost severial times.

Now, the Bi Luo define Ans[i] as the most value can bi Luo gets if bi Luo starts at node i.

Bi Luo is also a excited boy, now him wants to know every], can you help ans[i?
Input a positive integer t (t≤104), represents there are t test cases.

Four each test:

The contain an integer N (n≤105).

The next line contains N integers v[i], which means the treasure ' s value of node I (1≤v[i]≤104).

For the next

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.