Spectral::Cup 2026 Round 2 (Codeforces Round 1100, Div. 1 + Div. 2)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2229 Spectral::Cup 2026 Round 2 (Codeforces Round 1100, Div. 1 + Div. 2) FINISHED False 10800 833086 May 23, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 117 ) I The Endians PROGRAMMING dp trees

You are given a tree of (n) nodes, where node (i) has weight (w_i), and an integer (k). Let the tree be rooted at node (x). You may select a subset (S) of the nodes such that (|S| = k) and (x \in S). Let (f(i)) be the sum of the weights of all nodes in (S) on the path from node (i) to the root. The score of (S) is (\sum_{i \in S} f(i)). For each node (1 \le x \le n), find the maximum possible score among all subsets (S) if the tree is rooted at node (x). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 500)). The description of the test cases follows. The first line of each test case contains two integers (n) and (k) ((2 \le n \le 4000), (1 \le k \le n)). The second line of each test case contains (n) integers (w_1, w_2,\ldots, w_n) ((1 \le w_i \le 10^9)). Each of the next (n - 1) lines contains two integers (u) and (v) ((1 \le u, v \le n)), indicating that nodes (u) and (v) are connected by an edge. It is guaranteed that the given graph is a tree. It is guaranteed that the sum of (n) over all test cases does not exceed (4000). For each test case, print (n) integers. For each (x) from (1) to (n), print the maximum possible score among all subsets (S) if the tree is rooted at node (x). In the first test case, the tree is as follows: For each (1 \le x \le n), the following is an optimal set (S): (x = 1): (S = \{1, 2, 5\}); the score is ((2) + (12 + 2) + (9 + 2) = 27), (x = 2): (S = \{2, 4 ,5\}); the score is ((12) + (6 + 12) + (9 + 6 + 12) = 57), (x = 3): (S = \{2, 3, 5\}); the score is ((12 + 3) + (3) + (9 + 3) = 30), (x = 4): (S = \{2, 4, 5\}); the score is ((12 + 6) + (6) + (9 + 6) = 39), (x = 5): (S = \{2, 4 ,5\}); the score is ((12 + 6 + 9) + (6 + 9) + (9) = 51), (x = 6):

Tutorials

Spectral::Cup 2026 Round 2 (Codeforces Round 1100, Div. 1 + Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
375861325 jeetganatra I May 23, 2026, 7:25 p.m. OK C++17 (GCC 7-32) TESTS 70 203 61542400
375882781 OrangeEye I May 24, 2026, 3:13 a.m. OK C++17 (GCC 7-32) TESTS 70 765 644403200
375861645 vgo96 I May 23, 2026, 7:28 p.m. OK C++17 (GCC 7-32) TESTS 70 1843 320921600

remove filters

Back to search problems