Codeforces Round 1075 (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
2189 Codeforces Round 1075 (Div. 2) FINISHED False 7200 7226723 Jan. 23, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 216 ) F Zhora the Vacuum Cleaner PROGRAMMING dp implementation sortings trees

Once upon a time, Zhora the Vacuum Cleaner found a big container with nuts that is represented by a tree with (n) vertices. Initially, in the (i)-th vertex, there are (a_i) nuts. What Zhora the Vacuum Cleaner likes most is eating nuts, so he decided to eat all the nuts. To save electricity, the vacuum cleaner can rearrange the nuts in the container beforehand. Zhora can choose a vertex (v) of the tree, and for every vertex (u \ne v), in non-increasing order of the length of path (uv), if (u) contains at least one nut, one nut from (u) moves into the closest vertex to (v) among (u)'s adjacent vertices. This operation requires (p) electricity units. After performing several such operations (possibly none), Zhora the Vacuum Cleaner eats all the nuts from every vertex, spending (q) electricity units per every vertex that contains nuts. What is the minimum amount of electricity units required to eat all the nuts? Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains three integers (n), (p), and (q) ((2 \le n \le 10^5), (0 \le p, q \le 10^6)) — the number of vertices in the container's tree and the required amounts of electricity for operations of types 1 and 2, respectively. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((0 \le a_i \le 10^6)) — the quantities of nuts in the vertices. Each of the next (n - 1) lines of each test case contains two integers (u) and (v) ((1 \le u, v \le n, u \ne v)), representing an undirected tree edge from vertex (u) to vertex (v). It is guaranteed that the given edges form a tree. It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, output the minimum amount of electricity units required

Tutorials

Codeforces Round 1075 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
359455241 btwo F Jan. 23, 2026, 5:41 p.m. OK C++17 (GCC 7-32) TESTS 31 140 10649600
359440612 i_love_i_love_huyhau6a2 F Jan. 23, 2026, 4:25 p.m. OK C++17 (GCC 7-32) TESTS 31 187 9523200
359442163 Zemu_Zzz F Jan. 23, 2026, 4:28 p.m. OK C++17 (GCC 7-32) TESTS 31 218 10035200
359444476 CodeByRachit F Jan. 23, 2026, 4:32 p.m. OK C++17 (GCC 7-32) TESTS 31 390 29900800
359494518 ra_hulYadav669 F Jan. 24, 2026, 4:36 a.m. OK C++20 (GCC 13-64) TESTS 31 125 15667200
359491215 Furioso_Slient F Jan. 24, 2026, 3:43 a.m. OK C++20 (GCC 13-64) TESTS 31 156 7782400
359461032 Kobe_Bryant_Laoda F Jan. 23, 2026, 6:23 p.m. OK C++20 (GCC 13-64) TESTS 31 156 9523200
359473176 bajajshivam178 F Jan. 23, 2026, 8:30 p.m. OK C++20 (GCC 13-64) TESTS 31 265 35328000
359497518 ANfi F Jan. 24, 2026, 5:08 a.m. OK C++20 (GCC 13-64) TESTS 31 406 21094400
359444628 mainkkk F Jan. 23, 2026, 4:32 p.m. OK C++20 (GCC 13-64) TESTS 31 484 23244800
359450341 RDDCCD F Jan. 23, 2026, 5:11 p.m. OK C++20 (GCC 13-64) TESTS 31 531 91955200
359444049 kaiboy F Jan. 23, 2026, 4:31 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 2560000
359504557 WEirdows F Jan. 24, 2026, 6:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 31 109 15155200
359474432 The_Mad_Max F Jan. 23, 2026, 8:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 125 18944000
359477585 VanshRA F Jan. 23, 2026, 9:47 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 125 30720000
359498500 StelIawinD F Jan. 24, 2026, 5:17 a.m. OK C++23 (GCC 14-64, msys2) TESTS 31 156 16281600
359468578 ali2005_syr F Jan. 23, 2026, 7:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 156 20275200
359439420 XVIII F Jan. 23, 2026, 4:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 171 6348800
359478409 VanshRA F Jan. 23, 2026, 10:05 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 171 26521600
359439670 aimoon F Jan. 23, 2026, 4:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 31 187 18227200
359499009 JessieQY F Jan. 24, 2026, 5:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 31 218 14848000
359456191 _OneMoreTest F Jan. 23, 2026, 5:48 p.m. OK Go TESTS 31 390 34099200
359449550 Nikrien F Jan. 23, 2026, 5:07 p.m. OK PyPy 3-64 TESTS 31 359 62873600
359485099 Little_Sheep_Yawn F Jan. 24, 2026, 1:33 a.m. OK PyPy 3-64 TESTS 31 437 31539200
359445494 Sacred_Conqurer F Jan. 23, 2026, 4:33 p.m. OK PyPy 3-64 TESTS 31 703 53555200
359443869 drydock F Jan. 23, 2026, 4:31 p.m. OK Rust 2024 TESTS 31 250 42188800

remove filters

Back to search problems