Educational Codeforces Round 158 (Rated for 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
1901 Educational Codeforces Round 158 (Rated for Div. 2) FINISHED False 7200 30986699 Nov. 24, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1572 ) E Compressed Tree PROGRAMMING dfs and similar dp graphs greedy trees

B"You are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to a_i . You can perform the following operation any number of times (possibly zero): Note that you can delete all vertices. After all operations are done, you're compressing the tree. The compression process is done as follows. While there is a vertex having exactly 2 incident edges in the tree, perform the following operation: It can be shown that if there are multiple ways to choose a vertex to delete during the compression process, the resulting tree is still the same. Your task is to calculate the maximum possible sum of numbers written on vertices after applying the aforementioned operation any number of times, and then compressing the tree. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains a single integer n ( 2 <= n <= 5 cdot 10^5 ) -- the number of vertices. The second line contains n integers a_1, a_2, ... , a_n ( -10^9 <= a_i <= 10^9 ). Each of the next n - 1 lines describes an edge of the tree. Edge i is denoted by two integers v_i and u_i , the labels of vertices it connects ( 1 <= v_i, u_i <= n , v_i ne u_i ). These edges form a tree. Additional constraint on the input: the sum of n over all test cases doesn't exceed 5 cdot 10^5 . For each test case, print a single integer -- the maximum possible sum of numbers written on vertices after applying the aforementioned operation any number of times, and then compressing the tree. "...

Tutorials

Educational Codeforces Round 158 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
234130152 Gassa E Nov. 24, 2023, 5:45 p.m. OK D TESTS 47 1169 212582400
234127147 Gassa E Nov. 24, 2023, 5:24 p.m. OK D TESTS 47 1294 105267200
234128128 Gassa E Nov. 24, 2023, 5:30 p.m. OK D TESTS 47 1372 178176000
234126378 Unk1ndled E Nov. 24, 2023, 5:19 p.m. OK GNU C11 TESTS 47 436 68812800
234172156 RernaG E Nov. 25, 2023, 4:20 a.m. OK GNU C++14 TESTS 47 545 102502400
234111662 KevinLikesCoding E Nov. 24, 2023, 4:24 p.m. OK GNU C++14 TESTS 47 577 65433600
234138218 Joacru E Nov. 24, 2023, 6:46 p.m. OK GNU C++14 TESTS 47 639 68812800
234117493 lerasimus E Nov. 24, 2023, 4:34 p.m. OK GNU C++14 TESTS 47 655 72908800
234159245 6945930042DucLA E Nov. 25, 2023, 12:03 a.m. OK GNU C++14 TESTS 47 701 114585600
234157364 omeganot E Nov. 24, 2023, 11:04 p.m. OK GNU C++14 TESTS 47 717 82124800
234125225 H0wl-iwnl E Nov. 24, 2023, 5:11 p.m. OK GNU C++14 TESTS 47 717 103321600
234124437 newone2023 E Nov. 24, 2023, 5:07 p.m. OK GNU C++14 TESTS 47 732 104140800
234164027 Naughty_Snippets E Nov. 25, 2023, 2:01 a.m. OK GNU C++14 TESTS 47 733 84889600
234124513 zhouchenfeng E Nov. 24, 2023, 5:08 p.m. OK GNU C++14 TESTS 47 748 86528000
234112852 KroosTheKeenGlint E Nov. 24, 2023, 4:27 p.m. OK GNU C++17 TESTS 47 530 68812800
234113050 phirtheta E Nov. 24, 2023, 4:27 p.m. OK GNU C++17 TESTS 47 592 113152000
234169231 JCS E Nov. 25, 2023, 3:35 a.m. OK GNU C++17 TESTS 47 655 84070400
234157921 EvenToWorldFinal E Nov. 24, 2023, 11:20 p.m. OK GNU C++17 TESTS 47 670 48230400
234169435 ktuanlamson E Nov. 25, 2023, 3:39 a.m. OK GNU C++17 TESTS 47 670 64000000
234180923 foammm E Nov. 25, 2023, 5:52 a.m. OK GNU C++17 TESTS 47 670 81715200
234169147 JCS E Nov. 25, 2023, 3:34 a.m. OK GNU C++17 TESTS 47 670 84070400
234148509 horrlod E Nov. 24, 2023, 8:31 p.m. OK GNU C++17 TESTS 47 670 92364800
234142848 ftuknights E Nov. 24, 2023, 7:28 p.m. OK GNU C++17 TESTS 47 686 65638400
234123633 Geanina_the_Great E Nov. 24, 2023, 5:03 p.m. OK GNU C++17 TESTS 47 686 75673600
234175261 chappy1 E Nov. 25, 2023, 4:57 a.m. OK GNU C++17 (64) TESTS 47 577 113356800
234114355 QwQwf E Nov. 24, 2023, 4:30 p.m. OK GNU C++17 (64) TESTS 47 592 113356800
234175533 errormakers E Nov. 25, 2023, 5 a.m. OK GNU C++17 (64) TESTS 47 592 120115200
234127562 PLA_Nh E Nov. 24, 2023, 5:26 p.m. OK GNU C++17 (64) TESTS 47 607 119808000
234119525 lunchbox E Nov. 24, 2023, 4:42 p.m. OK GNU C++17 (64) TESTS 47 607 120934400
234127382 PLA_Nh E Nov. 24, 2023, 5:25 p.m. OK GNU C++17 (64) TESTS 47 608 119808000
234175486 errormakers E Nov. 25, 2023, 5 a.m. OK GNU C++17 (64) TESTS 47 623 120115200
234125713 wangjunchao E Nov. 24, 2023, 5:14 p.m. OK GNU C++17 (64) TESTS 47 638 120422400
234164272 anhkha1004 E Nov. 25, 2023, 2:06 a.m. OK GNU C++17 (64) TESTS 47 639 97177600
234119996 prairie2022 E Nov. 24, 2023, 4:44 p.m. OK GNU C++17 (64) TESTS 47 639 100556800
234128530 AuroraAlaska E Nov. 24, 2023, 5:33 p.m. OK GNU C++20 (64) TESTS 47 358 122777600
234166516 llzzxx712 E Nov. 25, 2023, 2:47 a.m. OK GNU C++20 (64) TESTS 47 358 138035200
234128589 AuroraAlaska E Nov. 24, 2023, 5:34 p.m. OK GNU C++20 (64) TESTS 47 405 86732800
234118084 kaiboy E Nov. 24, 2023, 4:37 p.m. OK GNU C++20 (64) TESTS 47 436 77926400
234109955 smallfangAKIOI E Nov. 24, 2023, 4:21 p.m. OK GNU C++20 (64) TESTS 47 436 91955200
234160848 sadboizz E Nov. 25, 2023, 12:49 a.m. OK GNU C++20 (64) TESTS 47 498 97280000
234157793 martins E Nov. 24, 2023, 11:16 p.m. OK GNU C++20 (64) TESTS 47 514 104140800
234139540 akshaykhandelwal E Nov. 24, 2023, 6:57 p.m. OK GNU C++20 (64) TESTS 47 514 107622400
234120897 syop E Nov. 24, 2023, 4:49 p.m. OK GNU C++20 (64) TESTS 47 514 107724800
234147475 maqi_maqi E Nov. 24, 2023, 8:19 p.m. OK GNU C++20 (64) TESTS 47 514 111616000
234121368 Dukkha E Nov. 24, 2023, 4:51 p.m. OK Java 17 TESTS 47 608 44851200
234169315 yvbf E Nov. 25, 2023, 3:37 a.m. OK Java 8 TESTS 47 857 106393600
234170356 yvbf E Nov. 25, 2023, 3:53 a.m. OK Java 8 TESTS 47 857 106496000
234167326 yvbf E Nov. 25, 2023, 3:02 a.m. OK Java 8 TESTS 47 857 151244800
234169570 yvbf E Nov. 25, 2023, 3:41 a.m. OK Java 8 TESTS 47 966 106393600
234169077 yvbf E Nov. 25, 2023, 3:33 a.m. OK Java 8 TESTS 47 1075 121548800
234138349 yuki_keshiki E Nov. 24, 2023, 6:47 p.m. OK PyPy 3-64 TESTS 47 842 115916800
234127079 misorin E Nov. 24, 2023, 5:23 p.m. OK PyPy 3-64 TESTS 47 842 115916800
234159965 liupengsay E Nov. 25, 2023, 12:25 a.m. OK PyPy 3-64 TESTS 47 1357 127590400
234159028 liupengsay E Nov. 24, 2023, 11:56 p.m. OK PyPy 3-64 TESTS 47 1372 137523200
234170605 yuki_keshiki E Nov. 25, 2023, 3:57 a.m. OK PyPy 3-64 TESTS 47 1403 156569600
234159713 liupengsay E Nov. 25, 2023, 12:18 a.m. OK PyPy 3-64 TESTS 47 1465 128921600
234159695 liupengsay E Nov. 25, 2023, 12:18 a.m. OK PyPy 3-64 TESTS 47 1606 141312000
234160494 SoleProprietor E Nov. 25, 2023, 12:40 a.m. OK PyPy 3-64 TESTS 47 1637 131891200
234159413 SoleProprietor E Nov. 25, 2023, 12:08 a.m. OK PyPy 3-64 TESTS 47 1668 132300800
234169647 yuki_keshiki E Nov. 25, 2023, 3:42 a.m. OK PyPy 3-64 TESTS 47 1700 165171200
234114244 cpchenpi E Nov. 24, 2023, 4:29 p.m. OK Rust 2021 TESTS 47 670 194048000
234151940 andrey.m E Nov. 24, 2023, 9:19 p.m. OK Rust 2021 TESTS 47 873 188211200
234123784 Vercingetorix E Nov. 24, 2023, 5:03 p.m. OK Rust 2021 TESTS 47 904 188211200
234119201 robostac E Nov. 24, 2023, 4:41 p.m. OK Rust 2021 TESTS 47 1918 206745600

remove filters

Back to search problems