Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"You're given a tree consisting of n nodes. Every node u has a weight a_u . It is guaranteed that there is only one node with minimum weight in the tree. For every node u (except for the node with the minimum weight), it must have a neighbor v such that a_v<a_u . You should construct a tree to minimize the weight w calculated as follows: The first line contains the integer n (2 <= n <= 5 cdot 10^5) , the number of nodes in the tree. The second line contains n space-separated integers a_1, a_2, ldots, a_n (1 <= a_i <= 10^9) , the weights of the nodes. The next n-1 lines, each contains 2 space-separated integers u and v (1 <= u,v <= n) which means there's an edge between u and v . Output one integer, the minimum possible value for w . In the first sample, the tree itself minimizes the value of w . In the second sample, the optimal tree is: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
46834621 |
__Ressed__ |
F |
Dec. 10, 2018, 12:15 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
296 |
60108800 |
|
3000 |
48654204 |
ReaLNero1 |
F |
Jan. 21, 2019, 1:24 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
327 |
56115200 |
|
3000 |
48462649 |
mmmod_lqs |
F |
Jan. 16, 2019, 3:30 p.m. |
OK |
GNU C++11 |
TESTS |
60 |
327 |
56115200 |
|
3000 |
53892448 |
Miracle_2001 |
F |
May 9, 2019, 2:03 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
343 |
68096000 |
|
3000 |
51431702 |
ww3113306 |
F |
March 18, 2019, 1:19 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
452 |
92160000 |
|
3000 |
53985146 |
luogu_bot1 |
F |
May 11, 2019, 9:14 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
452 |
132198400 |
|
3000 |
46716967 |
yao11617 |
F |
Dec. 7, 2018, 11:44 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
467 |
46080000 |
|
3000 |
46717273 |
SshenYyu |
F |
Dec. 7, 2018, 11:53 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
467 |
128204800 |
|
3000 |
46630206 |
ErkkiErkko |
F |
Dec. 5, 2018, 2:10 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
499 |
98099200 |
|
3000 |
46636271 |
was_n |
F |
Dec. 5, 2018, 6:53 a.m. |
OK |
GNU C++11 |
TESTS |
60 |
514 |
64102400 |
|
3000 |
47028831 |
Rabbittank |
F |
Dec. 15, 2018, 8:34 a.m. |
OK |
GNU C++14 |
TESTS |
60 |
514 |
78131200 |
|
3000 |
46697454 |
NiceBaseballCoder |
F |
Dec. 6, 2018, 9:03 p.m. |
OK |
GNU C++14 |
TESTS |
60 |
545 |
50278400 |
|
3000 |
46639926 |
Hamzqq9 |
F |
Dec. 5, 2018, 9:01 a.m. |
OK |
GNU C++14 |
TESTS |
60 |
561 |
50278400 |
|
3000 |
46919242 |
purple_bro |
F |
Dec. 12, 2018, 2:21 a.m. |
OK |
GNU C++14 |
TESTS |
60 |
592 |
124211200 |
|
3000 |
47036017 |
purple_bro |
F |
Dec. 15, 2018, 12:15 p.m. |
OK |
GNU C++14 |
TESTS |
60 |
592 |
128204800 |
|
3000 |
47329068 |
hank55663 |
F |
Dec. 21, 2018, 11:57 a.m. |
OK |
GNU C++14 |
TESTS |
60 |
639 |
58880000 |
|
3000 |
47449800 |
jslijin |
F |
Dec. 24, 2018, 8:51 a.m. |
OK |
GNU C++14 |
TESTS |
60 |
654 |
58265600 |
|
3000 |
47535562 |
eidan |
F |
Dec. 27, 2018, 12:48 a.m. |
OK |
GNU C++14 |
TESTS |
60 |
670 |
70246400 |
|
3000 |
68962824 |
LANDDKPLA |
F |
Jan. 17, 2020, 2:37 a.m. |
OK |
GNU C++14 |
TESTS |
60 |
702 |
164249600 |
|
3000 |
46613258 |
supersayadilson |
F |
Dec. 4, 2018, 4:01 p.m. |
OK |
GNU C++14 |
TESTS |
60 |
716 |
61132800 |
|
3000 |
46700747 |
Elegia |
F |
Dec. 7, 2018, 1:56 a.m. |
OK |
GNU C++17 |
TESTS |
60 |
529 |
54476800 |
|
3000 |
46700802 |
KrK |
F |
Dec. 7, 2018, 2:01 a.m. |
OK |
GNU C++17 |
TESTS |
60 |
623 |
50278400 |
|
3000 |
46989069 |
kmjp |
F |
Dec. 14, 2018, 12:45 a.m. |
OK |
GNU C++17 |
TESTS |
60 |
639 |
50380800 |
|
3000 |
49761888 |
amnesiac_dusk |
F |
Feb. 11, 2019, 9:26 a.m. |
OK |
GNU C++17 |
TESTS |
60 |
701 |
66150400 |
|
3000 |
52230339 |
tkj |
F |
April 2, 2019, 11:39 a.m. |
OK |
GNU C++17 |
TESTS |
60 |
701 |
92160000 |
|
3000 |
46760061 |
haleyk100198 |
F |
Dec. 8, 2018, 12:59 p.m. |
OK |
GNU C++17 |
TESTS |
60 |
702 |
80281600 |
|
3000 |
46768151 |
Trote_w |
F |
Dec. 8, 2018, 3:26 p.m. |
OK |
GNU C++17 |
TESTS |
60 |
702 |
185139200 |
|
3000 |
53727987 |
Kmcode |
F |
May 4, 2019, 5:42 a.m. |
OK |
GNU C++17 |
TESTS |
60 |
716 |
78643200 |
|
3000 |
46951536 |
mohamedeltair |
F |
Dec. 12, 2018, 8:56 p.m. |
OK |
GNU C++17 |
TESTS |
60 |
717 |
68300800 |
|
3000 |
46688175 |
Holidin |
F |
Dec. 6, 2018, 2:59 p.m. |
OK |
GNU C++17 |
TESTS |
60 |
732 |
80281600 |
|
3000 |
48784632 |
donli |
F |
Jan. 23, 2019, 8:23 a.m. |
OK |
Java 8 |
TESTS |
60 |
1450 |
175411200 |
|
3000 |
46637373 |
alexjthat |
F |
Dec. 5, 2018, 7:35 a.m. |
OK |
Java 8 |
TESTS |
60 |
1778 |
108339200 |
|
3000 |
46915394 |
whiteChicken |
F |
Dec. 11, 2018, 7:55 p.m. |
OK |
Java 8 |
TESTS |
60 |
1840 |
219750400 |
|
3000 |
49879952 |
ISSAM_LAKOUAM |
F |
Feb. 13, 2019, 5:41 p.m. |
OK |
Java 8 |
TESTS |
60 |
2137 |
182988800 |
|
3000 |
46915452 |
whiteChicken |
F |
Dec. 11, 2018, 7:59 p.m. |
OK |
Java 8 |
TESTS |
60 |
2214 |
182988800 |
|
3000 |
47852566 |
sweiss |
F |
Jan. 2, 2019, 6:49 p.m. |
OK |
Java 8 |
TESTS |
60 |
2308 |
264499200 |
|
3000 |
46694736 |
moss3s |
F |
Dec. 6, 2018, 6:46 p.m. |
OK |
Kotlin |
TESTS |
60 |
997 |
133017600 |
|
3000 |
46694309 |
moss3s |
F |
Dec. 6, 2018, 6:29 p.m. |
OK |
Kotlin |
TESTS |
60 |
1825 |
268390400 |
|
3000 |
51458940 |
P___ |
F |
March 18, 2019, 6:30 p.m. |
OK |
MS C++ 2017 |
TESTS |
60 |
638 |
34406400 |
|
3000 |
remove filters
Back to search problems