Codeforces Round 1098 (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
2228 Codeforces Round 1098 (Div. 2) FINISHED False 8100 1437887 May 16, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 272 ) F Momoyo and the Network PROGRAMMING binary search dfs and similar divide and conquer dp trees

The Underground Great Line Network is a grand transit system connecting all corners of Gensokyo. Momoyo noticed that the network's layout resembled a tree(^{\text{∗}}) structure. She couldn't help but imagine the most effective way to dismantle that tree. Given a tree with (n) nodes where node (i) has weight (a_i), select a simple path of exactly (k) edges and remove all edges on it. This splits the tree into (k+1) connected components, each with weight equal to the sum of its nodes' weights. You need to maximize the minimum component weight, or output (-1) if no simple path of exactly (k) edges exists. (^{\text{∗}})A tree is a connected graph without cycles. 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 two integers (n) and (k) ((1 \le k \le n-1), (2 \le n \le 2 \cdot 10^5)). The second line contains (n) integers, where the (i)-th integer represents (a_i) ((1 \le a_i \le 10^9)). The next (n-1) lines each contain two integers (u) and (v), representing an edge of the tree. It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, output the maximum possible minimum component weight, or (-1) if no such path exists. In the first test case, consider the path (3\to4). Removing this path yields components of weights (6) and (4). In the fourth test case, take the path (1\to2\to5). Removing this path yields components of weights (7), (6), and (9).

Tutorials

Codeforces Round 1098 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
374895998 bit1ift F May 17, 2026, 4:34 a.m. OK C++17 (GCC 7-32) TESTS 56 531 17100800
374850767 wahi_Piu F May 16, 2026, 4:42 p.m. OK C++17 (GCC 7-32) TESTS 56 625 16281600
374849464 juixe F May 16, 2026, 4:40 p.m. OK C++17 (GCC 7-32) TESTS 56 1453 31232000
374894113 king_0 F May 17, 2026, 4:08 a.m. OK C++17 (GCC 7-32) TESTS 56 1703 16896000
374845966 Rakesh_Sh05ma F May 16, 2026, 4:33 p.m. OK C++17 (GCC 7-32) TESTS 56 1734 20070400
374903500 notmerblx F May 17, 2026, 5:54 a.m. OK C++17 (GCC 7-32) TESTS 56 2234 1536000
374852794 bettercallwael F May 16, 2026, 4:46 p.m. OK C++17 (GCC 7-32) TESTS 56 2265 13414400
374884985 s-ahmad461 F May 17, 2026, 2:12 a.m. OK C++17 (GCC 7-32) TESTS 56 2562 15872000
374852190 Linus_Eisenberg F May 16, 2026, 4:45 p.m. OK C++17 (GCC 7-32) TESTS 56 2750 24780800
374902759 notmerblx F May 17, 2026, 5:47 a.m. OK C++17 (GCC 7-32) TESTS 56 2828 18944000
374851205 Suwan F May 16, 2026, 4:43 p.m. OK C++20 (GCC 13-64) TESTS 56 781 18329600
374885094 ramumali2002 F May 17, 2026, 2:14 a.m. OK C++20 (GCC 13-64) TESTS 56 828 31846400
374854477 fibonacci_6869 F May 16, 2026, 4:48 p.m. OK C++20 (GCC 13-64) TESTS 56 890 30105600
374880634 CutSandstone F May 16, 2026, 11:50 p.m. OK C++20 (GCC 13-64) TESTS 56 1031 31948800
374880458 gerkghdri F May 16, 2026, 11:44 p.m. OK C++20 (GCC 13-64) TESTS 56 1093 22937600
374880865 _lbw_ F May 16, 2026, 11:58 p.m. OK C++20 (GCC 13-64) TESTS 56 1578 92774400
374849003 onbert F May 16, 2026, 4:39 p.m. OK C++20 (GCC 13-64) TESTS 56 1609 33587200
374852916 a_patra F May 16, 2026, 4:46 p.m. OK C++20 (GCC 13-64) TESTS 56 1640 12697600
374864574 gevak F May 16, 2026, 7:03 p.m. OK C++20 (GCC 13-64) TESTS 56 1687 33177600
374870491 manwhatcanisay F May 16, 2026, 8:03 p.m. OK C++20 (GCC 13-64) TESTS 56 1703 34713600
374869458 SDSXC F May 16, 2026, 7:49 p.m. OK C++23 (GCC 14-64, msys2) TESTS 56 328 49254400
374870886 nice333 F May 16, 2026, 8:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 56 625 25292800
374853888 fastmath F May 16, 2026, 4:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 56 687 46899200
374892941 y_himanshu F May 17, 2026, 3:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 56 828 17100800
374886430 Edu175 F May 17, 2026, 2:41 a.m. OK C++23 (GCC 14-64, msys2) TESTS 56 843 67276800
374850259 mo_mo_yu F May 16, 2026, 4:41 p.m. OK C++23 (GCC 14-64, msys2) TESTS 56 921 23961600
374887115 Edu175 F May 17, 2026, 2:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 56 921 67072000
374887067 Edu175 F May 17, 2026, 2:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 56 921 67276800
374895254 masy2011 F May 17, 2026, 4:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 56 937 13619200
374852686 gefganty F May 16, 2026, 4:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 56 937 17920000
374853549 loveax F May 16, 2026, 4:47 p.m. OK GNU C11 TESTS 56 328 17715200
374853020 Meren4 F May 16, 2026, 4:46 p.m. OK GNU C11 TESTS 56 2125 30208000
374853468 matheussricardoo F May 16, 2026, 4:47 p.m. OK Go TESTS 56 1515 85913600
374848500 2310030373 F May 16, 2026, 4:38 p.m. OK Java 21 TESTS 56 1765 8601600
374854629 RituRajSingh F May 16, 2026, 4:49 p.m. OK Java 21 TESTS 56 2078 43110400
374876148 harsh08 F May 16, 2026, 9:40 p.m. OK Java 8 TESTS 56 2218 6144000
374889872 A_G F May 17, 2026, 3:41 a.m. OK Rust 2024 TESTS 56 2406 45670400

remove filters

Back to search problems