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 are given a tree, which consists of n vertices. Recall that a tree is a connected undirected graph without cycles. Vertices are numbered from 1 to n . All vertices have weights, the weight of the vertex v is a_v . Recall that the distance between two vertices in the tree is the number of edges on a simple path between them. Your task is to find the subset of vertices with the maximum total weight (the weight of the subset is the sum of weights of all vertices in it) such that there is no pair of vertices with the distance k or less between them in this subset. The first line of the input contains two integers n and k ( 1 <= n, k <= 200 ) -- the number of vertices in the tree and the distance restriction, respectively. The second line of the input contains n integers a_1, a_2, ... , a_n ( 1 <= a_i <= 10^5 ), where a_i is the weight of the vertex i . The next n - 1 lines contain edges of the tree. Edge i is denoted by two integers u_i and v_i -- the labels of vertices it connects ( 1 <= u_i, v_i <= n , u_i ne v_i ). It is guaranteed that the given edges form a tree. Print one integer -- the maximum total weight of the subset in which all pairs of vertices have distance more than k . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
65725387 |
asorak |
F |
Nov. 25, 2019, 10:19 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
82 |
46 |
4300800 |
|
2500 |
65674072 |
asorak |
F |
Nov. 24, 2019, 5:12 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
82 |
46 |
9523200 |
|
2500 |
65675265 |
asorak |
F |
Nov. 24, 2019, 5:41 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
82 |
62 |
9523200 |
|
2500 |
64645473 |
Evocation |
F |
Nov. 10, 2019, 2:47 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
82 |
343 |
4403200 |
|
2500 |
66571839 |
yuzhechuan |
F |
Dec. 10, 2019, 5:08 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
66571725 |
yuzhechuan |
F |
Dec. 10, 2019, 5:03 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
66251995 |
luyuchen |
F |
Dec. 4, 2019, 2:49 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
66082138 |
ValiZpg |
F |
Dec. 1, 2019, 1:03 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
65659386 |
luogu_bot4 |
F |
Nov. 24, 2019, 11:46 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
64499377 |
vjudge2 |
F |
Nov. 8, 2019, 3:04 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
64281942 |
huangzhen |
F |
Nov. 5, 2019, 2:28 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
64192575 |
SakuraWuSiDa |
F |
Nov. 4, 2019, 8:21 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
64140567 |
Hust_Konnyaku |
F |
Nov. 3, 2019, 8:25 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
63983766 |
luogu_bot3 |
F |
Nov. 1, 2019, 11:07 a.m. |
OK |
GNU C++11 |
TESTS |
82 |
31 |
0 |
|
2500 |
64342347 |
BestMSN |
F |
Nov. 6, 2019, 3:47 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
30 |
204800 |
|
2500 |
63219212 |
PrimeG |
F |
Oct. 23, 2019, 7:22 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
30 |
204800 |
|
2500 |
63774927 |
cocktail |
F |
Oct. 30, 2019, 9:12 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
30 |
307200 |
|
2500 |
67954933 |
1213James |
F |
Dec. 30, 2019, 9:15 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
31 |
0 |
|
2500 |
64342150 |
BestMSN |
F |
Nov. 6, 2019, 3:36 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
31 |
204800 |
|
2500 |
63756942 |
luoZH111 |
F |
Oct. 30, 2019, 12:19 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
31 |
204800 |
|
2500 |
63540424 |
Smiekids |
F |
Oct. 27, 2019, 9:08 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
31 |
204800 |
|
2500 |
63537753 |
MavericK_Frank |
F |
Oct. 27, 2019, 8:34 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
31 |
204800 |
|
2500 |
63499568 |
fqx |
F |
Oct. 26, 2019, 4:43 p.m. |
OK |
GNU C++14 |
TESTS |
82 |
31 |
204800 |
|
2500 |
63278316 |
SaInsist |
F |
Oct. 24, 2019, 7:48 a.m. |
OK |
GNU C++14 |
TESTS |
82 |
31 |
204800 |
|
2500 |
64611658 |
sir.kay |
F |
Nov. 10, 2019, 2:04 a.m. |
OK |
GNU C++17 |
TESTS |
82 |
30 |
307200 |
|
2500 |
63234242 |
starcy |
F |
Oct. 23, 2019, 11:52 a.m. |
OK |
GNU C++17 |
TESTS |
82 |
30 |
307200 |
|
2500 |
63203350 |
okwedook |
F |
Oct. 22, 2019, 9:54 p.m. |
OK |
GNU C++17 |
TESTS |
82 |
30 |
409600 |
|
2500 |
63214898 |
Lawali |
F |
Oct. 23, 2019, 5:41 a.m. |
OK |
GNU C++17 |
TESTS |
82 |
30 |
512000 |
|
2500 |
65748903 |
coyorkdow |
F |
Nov. 26, 2019, 1:16 p.m. |
OK |
GNU C++17 |
TESTS |
82 |
30 |
614400 |
|
2500 |
63201445 |
jagarwal |
F |
Oct. 22, 2019, 8:45 p.m. |
OK |
GNU C++17 |
TESTS |
82 |
30 |
819200 |
|
2500 |
63487375 |
yyh2000112 |
F |
Oct. 26, 2019, 1:37 p.m. |
OK |
GNU C++17 |
TESTS |
82 |
31 |
0 |
|
2500 |
63229474 |
Love_oneplus |
F |
Oct. 23, 2019, 10:28 a.m. |
OK |
GNU C++17 |
TESTS |
82 |
31 |
0 |
|
2500 |
63210394 |
A_root_A |
F |
Oct. 23, 2019, 3:22 a.m. |
OK |
GNU C++17 |
TESTS |
82 |
31 |
102400 |
|
2500 |
65936161 |
wish2lucky |
F |
Nov. 29, 2019, 2:19 a.m. |
OK |
GNU C++17 |
TESTS |
82 |
31 |
204800 |
|
2500 |
63773829 |
z20124528 |
F |
Oct. 30, 2019, 8:51 a.m. |
OK |
Go |
TESTS |
82 |
46 |
204800 |
|
2500 |
64331850 |
stefan.sakalik |
F |
Nov. 5, 2019, 7:42 p.m. |
OK |
Go |
TESTS |
82 |
78 |
0 |
|
2500 |
64330906 |
stefan.sakalik |
F |
Nov. 5, 2019, 7:16 p.m. |
OK |
Go |
TESTS |
82 |
124 |
0 |
|
2500 |
63722600 |
TheSawan |
F |
Oct. 29, 2019, 11:46 a.m. |
OK |
Java 11 |
TESTS |
82 |
218 |
0 |
|
2500 |
65750044 |
IslamTalipovTop |
F |
Nov. 26, 2019, 1:41 p.m. |
OK |
Java 11 |
TESTS |
82 |
233 |
0 |
|
2500 |
67685493 |
dyhu083 |
F |
Dec. 27, 2019, 8:40 a.m. |
OK |
Java 8 |
TESTS |
82 |
124 |
0 |
|
2500 |
67684040 |
dyhu083 |
F |
Dec. 27, 2019, 7:58 a.m. |
OK |
Java 8 |
TESTS |
82 |
139 |
0 |
|
2500 |
64484690 |
yaoct |
F |
Nov. 7, 2019, 5:17 p.m. |
OK |
Java 8 |
TESTS |
82 |
140 |
0 |
|
2500 |
63547281 |
icpc_loser |
F |
Oct. 27, 2019, 10:50 a.m. |
OK |
Java 8 |
TESTS |
82 |
140 |
0 |
|
2500 |
65982601 |
dalt |
F |
Nov. 29, 2019, 3:53 p.m. |
OK |
Java 8 |
TESTS |
82 |
140 |
19148800 |
|
2500 |
64527262 |
Nutella3000 |
F |
Nov. 8, 2019, 2:11 p.m. |
OK |
Java 8 |
TESTS |
82 |
155 |
0 |
|
2500 |
63420866 |
applemelon |
F |
Oct. 26, 2019, 6:21 a.m. |
OK |
Java 8 |
TESTS |
82 |
156 |
0 |
|
2500 |
63202254 |
phantom11 |
F |
Oct. 22, 2019, 9:15 p.m. |
OK |
Java 8 |
TESTS |
82 |
170 |
0 |
|
2500 |
63202480 |
phantom11 |
F |
Oct. 22, 2019, 9:23 p.m. |
OK |
Java 8 |
TESTS |
82 |
171 |
0 |
|
2500 |
64771135 |
barakraganosungam |
F |
Nov. 12, 2019, 11:48 p.m. |
OK |
Java 8 |
TESTS |
82 |
171 |
1843200 |
|
2500 |
64373249 |
vjudge2 |
F |
Nov. 6, 2019, 3:01 p.m. |
OK |
MS C++ |
TESTS |
82 |
31 |
307200 |
|
2500 |
64438986 |
vjudge2 |
F |
Nov. 7, 2019, 3:08 a.m. |
OK |
MS C++ |
TESTS |
82 |
46 |
204800 |
|
2500 |
63498276 |
vjudge4 |
F |
Oct. 26, 2019, 4:17 p.m. |
OK |
MS C++ |
TESTS |
82 |
46 |
204800 |
|
2500 |
63366796 |
r57shell |
F |
Oct. 25, 2019, 7:49 a.m. |
OK |
MS C++ |
TESTS |
82 |
62 |
307200 |
|
2500 |
63366712 |
r57shell |
F |
Oct. 25, 2019, 7:47 a.m. |
OK |
MS C++ |
TESTS |
82 |
77 |
512000 |
|
2500 |
64614814 |
_kong_ |
F |
Nov. 10, 2019, 4:09 a.m. |
OK |
MS C++ 2017 |
TESTS |
82 |
31 |
307200 |
|
2500 |
63878436 |
Kirundel |
F |
Oct. 30, 2019, 7:49 p.m. |
OK |
MS C++ 2017 |
TESTS |
82 |
31 |
512000 |
|
2500 |
63878015 |
Kirundel |
F |
Oct. 30, 2019, 7:40 p.m. |
OK |
MS C++ 2017 |
TESTS |
82 |
46 |
204800 |
|
2500 |
63245853 |
Prokopiy |
F |
Oct. 23, 2019, 2:38 p.m. |
OK |
MS C++ 2017 |
TESTS |
82 |
46 |
512000 |
|
2500 |
67789575 |
CygneNoir |
F |
Dec. 28, 2019, 2:07 p.m. |
OK |
MS C++ 2017 |
TESTS |
82 |
46 |
614400 |
|
2500 |
67788556 |
CygneNoir |
F |
Dec. 28, 2019, 1:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
82 |
46 |
614400 |
|
2500 |
63963065 |
zdbtxdy |
F |
Nov. 1, 2019, 6:05 a.m. |
OK |
PyPy 2 |
TESTS |
82 |
155 |
1433600 |
|
2500 |
64298008 |
EM1NEM |
F |
Nov. 5, 2019, 9:09 a.m. |
OK |
PyPy 2 |
TESTS |
82 |
156 |
1433600 |
|
2500 |
66869059 |
sritha |
F |
Dec. 14, 2019, 1:04 p.m. |
OK |
PyPy 3 |
TESTS |
82 |
155 |
2150400 |
|
2500 |
64156097 |
TilakSN |
F |
Nov. 3, 2019, 12:51 p.m. |
OK |
PyPy 3 |
TESTS |
82 |
170 |
2150400 |
|
2500 |
66273047 |
sruthi_1729 |
F |
Dec. 4, 2019, 12:59 p.m. |
OK |
PyPy 3 |
TESTS |
82 |
171 |
2150400 |
|
2500 |
66741828 |
pikmike |
F |
Dec. 12, 2019, 9:17 p.m. |
OK |
PyPy 3 |
TESTS |
82 |
171 |
2355200 |
|
2500 |
remove filters
Back to search problems