Manthan, Codefest 16

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
633 Manthan, Codefest 16 FINISHED False 9000 319898723 Feb. 26, 2016, 5:15 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1372 ) F The Chocolate Spree PROGRAMMING dfs and similar dp graphs trees 2500

Alice and Bob have a tree (undirected acyclic connected graph). There are a i chocolates waiting to be picked up in the i -th vertex of the tree. First, they choose two different vertices as their starting positions (Alice chooses first) and take all the chocolates contained in them. Then, they alternate their moves, selecting one vertex at a time and collecting all chocolates from this node. To make things more interesting, they decided that one can select a vertex only if he/she selected a vertex adjacent to that one at his/her previous turn and this vertex has not been already chosen by any of them during other move. If at any moment one of them is not able to select the node that satisfy all the rules, he/she will skip his turns and let the other person pick chocolates as long as he/she can. This goes on until both of them cannot pick chocolates any further. Due to their greed for chocolates, they want to collect as many chocolates as possible. However, as they are friends they only care about the total number of chocolates they obtain together . What is the maximum total number of chocolates they may pick? The first line of the input contains the single integer n ( 2 ≤ n ≤ 100 000 ) — the number of vertices in the tree. The second line contains n integers a i ( 1 ≤ a i ≤ 10 9 ), i -th of these numbers stands for the number of chocolates stored at the node i . Then follow n - 1 lines that describe the tree. Each of them contains two integers u i and v i ( 1 ≤ u i , v i ≤ n ) — indices of vertices connected by the i -th edge. Print the number of chocolates Alice and Bob can collect together if they behave optimally. In the first sample, Alice may start at the vertex 9 and Bob at vertex 8 . Alice will select vertex 1 and Bob has no options now. Alice selects the vertex 7 and they both stop. In the second sample, both of them will pick either of the nodes alternately.

Tutorials

Manthan, Codefest 16: Editorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
16467353 ligerre F March 2, 2016, 2:58 p.m. OK FPC TESTS 56 78 14540800 2500
16421608 ez_zkj F Feb. 29, 2016, 6:38 a.m. OK FPC TESTS 56 93 9932800 2500
16733539 SilverDH F March 15, 2016, 7:40 p.m. OK FPC TESTS 56 171 104243200 2500
21904327 ljh2000 F Oct. 31, 2016, 6:18 a.m. OK GNU C++ TESTS 56 31 5632000 2500
21904301 ljh2000 F Oct. 31, 2016, 6:16 a.m. OK GNU C++ TESTS 56 31 7680000 2500
21904281 ljh2000 F Oct. 31, 2016, 6:15 a.m. OK GNU C++ TESTS 56 31 11264000 2500
21963811 laofudasuan F Nov. 1, 2016, 10:29 a.m. OK GNU C++ TESTS 56 46 7270400 2500
21904391 ljh2000 F Oct. 31, 2016, 6:23 a.m. OK GNU C++ TESTS 56 46 7270400 2500
21909211 _Mashiro F Oct. 31, 2016, 10:59 a.m. OK GNU C++ TESTS 56 46 7680000 2500
40984967 ReaLNero1 F July 30, 2018, 7:40 p.m. OK GNU C++ TESTS 56 46 7782400 2500
21958825 LCF F Nov. 1, 2016, 6:46 a.m. OK GNU C++ TESTS 56 46 11264000 2500
27484824 jiyutian F June 1, 2017, 12:46 p.m. OK GNU C++ TESTS 56 46 16588800 2500
16722320 NanoApe F March 14, 2016, 11:52 p.m. OK GNU C++ TESTS 56 46 18227200 2500
64620071 luogu_bot5 F Nov. 10, 2019, 6:32 a.m. OK GNU C++11 TESTS 56 46 8192000 2500
63960421 Herry_NY F Nov. 1, 2019, 4:51 a.m. OK GNU C++11 TESTS 56 46 8192000 2500
63968088 luogu_bot4 F Nov. 1, 2019, 8:01 a.m. OK GNU C++11 TESTS 56 46 9932800 2500
61369315 Dream-chasing_Juvenile F Sept. 27, 2019, 2:29 p.m. OK GNU C++11 TESTS 56 46 10649600 2500
61369189 Dream-chasing_Juvenile F Sept. 27, 2019, 2:27 p.m. OK GNU C++11 TESTS 56 46 10649600 2500
60070647 babilonglong F Sept. 5, 2019, 11:01 a.m. OK GNU C++11 TESTS 56 46 11878400 2500
42324847 SovietPower F Sept. 1, 2018, 3:41 a.m. OK GNU C++11 TESTS 56 46 11878400 2500
60064308 babilong F Sept. 5, 2019, 8:27 a.m. OK GNU C++11 TESTS 56 46 13516800 2500
63993627 OuOu F Nov. 1, 2019, 1:54 p.m. OK GNU C++11 TESTS 56 46 14540800 2500
63960296 luogu_bot1 F Nov. 1, 2019, 4:47 a.m. OK GNU C++11 TESTS 56 46 14540800 2500
30570972 NiroBC F Sept. 21, 2017, 8:27 a.m. OK GNU C++14 TESTS 56 109 6860800 2500
31881687 Gealo F Oct. 30, 2017, 5:23 a.m. OK GNU C++14 TESTS 56 109 19353600 2500
31837516 danya.smelskiy F Oct. 28, 2017, 12:45 p.m. OK GNU C++14 TESTS 56 109 19763200 2500
45680615 minson123 F Nov. 13, 2018, 3:14 p.m. OK GNU C++14 TESTS 56 109 20377600 2500
32981427 NormalCoder F Dec. 6, 2017, 4:17 p.m. OK GNU C++14 TESTS 56 109 22835200 2500
32783611 lllllllllllllllllllllll F Nov. 29, 2017, 2:45 p.m. OK GNU C++14 TESTS 56 124 17203200 2500
53604516 ToRe F May 1, 2019, 9:38 a.m. OK GNU C++14 TESTS 56 124 18227200 2500
31881499 Gealo F Oct. 30, 2017, 5:09 a.m. OK GNU C++14 TESTS 56 124 18534400 2500
45919283 dai F Nov. 18, 2018, 3:36 p.m. OK GNU C++14 TESTS 56 124 23552000 2500
42322363 Marckess F Aug. 31, 2018, 11:38 p.m. OK GNU C++14 TESTS 56 124 27136000 2500
44834760 Ryuuk F Oct. 25, 2018, 10:19 a.m. OK GNU C++17 TESTS 56 61 32972800 2500
44885047 Ryuuk F Oct. 25, 2018, 9:16 p.m. OK GNU C++17 TESTS 56 62 33177600 2500
44777623 Ryuuk F Oct. 24, 2018, 3:03 p.m. OK GNU C++17 TESTS 56 62 33996800 2500
44771229 Ryuuk F Oct. 24, 2018, 12:28 p.m. OK GNU C++17 TESTS 56 62 35635200 2500
44769797 Ryuuk F Oct. 24, 2018, 11:49 a.m. OK GNU C++17 TESTS 56 77 35840000 2500
44767106 Ryuuk F Oct. 24, 2018, 10:31 a.m. OK GNU C++17 TESTS 56 78 35328000 2500
47968736 how_to_become_purple F Jan. 5, 2019, 1:27 p.m. OK GNU C++17 TESTS 56 109 18022400 2500
51402001 pzh_pzh F March 17, 2019, 7:53 a.m. OK GNU C++17 TESTS 56 109 18124800 2500
51154808 chinmay0906 F March 11, 2019, 10:04 a.m. OK GNU C++17 TESTS 56 109 22118400 2500
64071938 wangyc F Nov. 2, 2019, 7:41 a.m. OK GNU C++17 TESTS 56 124 16896000 2500
16366969 mkirsche F Feb. 26, 2016, 7:16 p.m. OK Java 7 TESTS 56 483 70553600 2500
16367769 Egor F Feb. 26, 2016, 7:24 p.m. OK Java 8 TESTS 56 186 25600000 2500
16374359 mmaxio F Feb. 27, 2016, 7:13 a.m. OK Java 8 TESTS 56 499 43110400 2500
16916354 dhrumil140396 F March 25, 2016, 5:54 a.m. OK Java 8 TESTS 56 561 86630400 2500
16865336 k790alex F March 22, 2016, 1:31 a.m. OK Java 8 TESTS 56 888 101888000 2500
16542429 joney_000 F March 5, 2016, 10:37 p.m. OK Java 8 TESTS 56 1559 116736000 2500
16366360 Taube F Feb. 26, 2016, 7:10 p.m. OK MS C++ TESTS 56 109 13619200 2500
16423013 iblacksun F Feb. 29, 2016, 8:47 a.m. OK MS C++ TESTS 56 109 27648000 2500
16667302 2015190026 F March 12, 2016, 7:09 a.m. OK MS C++ TESTS 56 140 24780800 2500
16376869 kingofnumbers F Feb. 27, 2016, 8:54 a.m. OK MS C++ TESTS 56 156 46899200 2500
16390860 Andrew.D.F F Feb. 27, 2016, 6:57 p.m. OK MS C++ TESTS 56 202 36864000 2500
16367118 alanM F Feb. 26, 2016, 7:18 p.m. OK MS C++ TESTS 56 1981 41574400 2500

remove filters

Back to search problems