Codeforces Round 358 (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
682 Codeforces Round 358 (Div. 2) FINISHED False 7200 265641899 June 17, 2016, 4:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 7284 ) C Alyona and the Tree PROGRAMMING dfs and similar dp graphs trees 1700

B"Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on. The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call vertex v sad if there is a vertex u in subtree of vertex v such that dist(v, xe2 x80 x89u) xe2 x80 x89> xe2 x80 x89au, where au is the number written on vertex u, dist(v, xe2 x80 x89u) is the sum of the numbers written on the edges on the path from v to u. Leaves of a tree are vertices connected to a single vertex by a single edge, but the root of a tree is a leaf if and only if the tree consists of a single vertex -- root. Thus Alyona decided to remove some of tree leaves until there will be no any sad vertex left in the tree. What is the minimum number of leaves Alyona needs to remove? In the first line of the input integer n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) is given -- the number of vertices in the tree. In the second line the sequence of n integers a1, xe2 x80 x89a2, xe2 x80 x89..., xe2 x80 x89an (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109) is given, where ai is the number written on vertex i. The next n xe2 x80 x89- xe2 x80 x891 lines describe tree edges: ith of them consists of two integers pi and ci (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89pi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x89- xe2 x80 x89109 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ci xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109), meaning that there is an edge connecting vertices i xe2 x80 x89+ xe2 x80 x891 and pi with number ci written on it. Print the only integer -- the minimum number of leaves Alyona needs to remove such that there will be no any sad vertex left in the tree. The following image represents possible process of removing leaves from the tree: "...

Tutorials

45491

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
20171797 WalkingDeade C Aug. 26, 2016, 9:16 a.m. OK FPC TESTS 106 62 11468800 1700
18569916 lerom C June 18, 2016, 2:51 a.m. OK FPC TESTS 104 77 4198400 1700
18569891 lerom C June 18, 2016, 2:48 a.m. OK FPC TESTS 104 77 5017600 1700
18630269 LossABike C June 21, 2016, 12:45 p.m. OK FPC TESTS 105 77 7168000 1700
20086127 Sanja C Aug. 23, 2016, 1:10 p.m. OK FPC TESTS 106 77 11878400 1700
18563854 nbvquang99 C June 17, 2016, 6:30 p.m. OK FPC TESTS 104 77 12902400 1700
18569093 dujunyi C June 18, 2016, 1:41 a.m. OK FPC TESTS 104 78 4096000 1700
23291661 HuyMaster10145 C Dec. 25, 2016, 9:27 a.m. OK FPC TESTS 106 78 11878400 1700
18667340 yan_lazy C June 23, 2016, 4:27 p.m. OK FPC TESTS 105 78 15769600 1700
19966604 Ahriman C Aug. 19, 2016, 3:18 p.m. OK FPC TESTS 106 78 18124800 1700
18660445 invisP C June 23, 2016, 9:11 a.m. OK GNU C TESTS 105 77 7168000 1700
18980976 wrongnumber Who1 windniw C July 9, 2016, 7:24 a.m. OK GNU C TESTS 106 77 9625600 1700
18586201 double301 C June 18, 2016, 7:46 p.m. OK GNU C TESTS 105 78 12185600 1700
27678380 JoeBlow C June 8, 2017, 8:09 p.m. OK GNU C TESTS 106 93 16179200 1700
19208488 vjudge5 C July 18, 2016, 9:27 a.m. OK GNU C TESTS 106 93 50073600 1700
18901426 adt7 C July 5, 2016, 1:09 p.m. OK GNU C TESTS 106 109 9830400 1700
18574411 jszyxw C June 18, 2016, 8:09 a.m. OK GNU C++ TESTS 104 31 3276800 1700
18575028 Gintoki C June 18, 2016, 8:42 a.m. OK GNU C++ TESTS 104 31 5222400 1700
21176164 zhanglexing C Oct. 4, 2016, 1:35 a.m. OK GNU C++ TESTS 106 31 9420800 1700
35110472 vjudge1 C Feb. 10, 2018, 3:30 a.m. OK GNU C++ TESTS 106 31 11673600 1700
18716059 Means C June 25, 2016, 8:35 a.m. OK GNU C++ TESTS 105 31 13619200 1700
26188047 vjudge5 C April 7, 2017, 9:04 a.m. OK GNU C++ TESTS 106 31 13721600 1700
40695564 vjudge1 C July 24, 2018, 7:52 a.m. OK GNU C++ TESTS 106 46 4505600 1700
40695507 SkyWT C July 24, 2018, 7:50 a.m. OK GNU C++ TESTS 106 46 4505600 1700
40695330 SkyWT C July 24, 2018, 7:45 a.m. OK GNU C++ TESTS 106 46 4505600 1700
40984312 ReaLNero1 C July 30, 2018, 7:18 p.m. OK GNU C++ TESTS 106 46 5120000 1700
56684500 rainboy C July 7, 2019, 8:59 p.m. OK GNU C11 TESTS 106 78 7577600 1700
65248175 vjudge4 C Nov. 17, 2019, 11:11 a.m. OK GNU C11 TESTS 106 93 16998400 1700
18691681 Oktavia C June 24, 2016, 1:10 a.m. OK GNU C++11 TESTS 105 31 5427200 1700
59508426 luogu_bot2 C Aug. 26, 2019, 7:03 a.m. OK GNU C++11 TESTS 106 31 6348800 1700
59511738 luogu_bot2 C Aug. 26, 2019, 8:15 a.m. OK GNU C++11 TESTS 106 31 6451200 1700
19444871 Bobocan C July 27, 2016, 3:46 p.m. OK GNU C++11 TESTS 106 31 10854400 1700
18594125 2014300227 C June 19, 2016, 8:43 a.m. OK GNU C++11 TESTS 105 31 11571200 1700
26373121 buctacm2 C April 15, 2017, 7:15 a.m. OK GNU C++11 TESTS 106 31 11776000 1700
19654378 yylidiw C Aug. 5, 2016, 3:21 p.m. OK GNU C++11 TESTS 106 31 19660800 1700
57433763 lukelin C July 21, 2019, 3:23 a.m. OK GNU C++11 TESTS 106 31 25804800 1700
57450209 Silvio_Manuel C July 21, 2019, 9:29 a.m. OK GNU C++11 TESTS 106 31 38502400 1700
18564362 spk C June 17, 2016, 6:34 p.m. OK GNU C++11 TESTS 104 46 3174400 1700
21176702 Xin-Jie C Oct. 4, 2016, 2:18 a.m. OK GNU C++14 TESTS 106 77 8908800 1700
63080663 Helman C Oct. 21, 2019, 3 p.m. OK GNU C++14 TESTS 106 78 10444800 1700
45561876 otaliptus C Nov. 11, 2018, 12:12 p.m. OK GNU C++14 TESTS 106 78 10956800 1700
36138126 Lucky_Sanae C March 10, 2018, 5:52 a.m. OK GNU C++14 TESTS 106 78 15667200 1700
57580957 vjudge4 C July 23, 2019, 8:50 a.m. OK GNU C++14 TESTS 106 78 15974400 1700
22487443 mengxiang000 C Nov. 25, 2016, 11:18 a.m. OK GNU C++14 TESTS 106 78 15974400 1700
27775140 vjudge2 C June 14, 2017, 2:10 p.m. OK GNU C++14 TESTS 106 93 4300800 1700
22270287 after C Nov. 16, 2016, 2:41 p.m. OK GNU C++14 TESTS 106 93 4403200 1700
41742599 fancycoser C Aug. 18, 2018, 6:19 a.m. OK GNU C++14 TESTS 106 93 5120000 1700
27530703 HadyKo C June 2, 2017, 7:29 p.m. OK GNU C++14 TESTS 106 93 5427200 1700
57973827 vjudge2 C July 30, 2019, 6:59 a.m. OK GNU C++17 TESTS 106 77 11161600 1700
57459584 HumHumMonster C July 21, 2019, 1:01 p.m. OK GNU C++17 TESTS 106 78 7782400 1700
62316535 vjudge4 C Oct. 10, 2019, 3:27 p.m. OK GNU C++17 TESTS 106 78 10444800 1700
40704340 qinyuyang C July 24, 2018, 12:34 p.m. OK GNU C++17 TESTS 106 78 15974400 1700
58788737 vjudge4 C Aug. 14, 2019, 1:10 a.m. OK GNU C++17 TESTS 106 92 5222400 1700
65595559 vjudge4 C Nov. 23, 2019, 3:44 p.m. OK GNU C++17 TESTS 106 92 6758400 1700
68325318 TSwiftie C Jan. 6, 2020, 4:39 p.m. OK GNU C++17 TESTS 106 93 6041600 1700
68325167 vjudge2 C Jan. 6, 2020, 4:35 p.m. OK GNU C++17 TESTS 106 93 6041600 1700
57445684 vjudge5 C July 21, 2019, 8:09 a.m. OK GNU C++17 TESTS 106 93 6758400 1700
57442017 vjudge1 C July 21, 2019, 7:03 a.m. OK GNU C++17 TESTS 106 93 6963200 1700
18573941 hanfei19910905 C June 18, 2016, 7:41 a.m. OK Go TESTS 104 93 24576000 1700
18573917 hanfei19910906 C June 18, 2016, 7:39 a.m. OK Go TESTS 104 93 24576000 1700
18573880 hanfei19910906 C June 18, 2016, 7:36 a.m. OK Go TESTS 104 124 31129600 1700
18572781 slycelote C June 18, 2016, 6:32 a.m. OK Haskell TESTS 104 390 50585600 1700
69227806 ypa C Jan. 21, 2020, 8:06 a.m. OK Java 11 TESTS 106 404 87654400 1700
18577967 chucha C June 18, 2016, 11:29 a.m. OK Java 7 TESTS 104 249 6553600 1700
18637712 smalex69 C June 21, 2016, 10:50 p.m. OK Java 7 TESTS 105 249 27238400 1700
18577934 chucha C June 18, 2016, 11:27 a.m. OK Java 7 TESTS 104 265 6451200 1700
18637701 smalex69 C June 21, 2016, 10:50 p.m. OK Java 7 TESTS 105 280 28774400 1700
19388443 keep.deep C July 24, 2016, 6:14 p.m. OK Java 7 TESTS 106 280 76697600 1700
18564032 deepraiya17 C June 17, 2016, 6:32 p.m. OK Java 7 TESTS 104 296 57753600 1700
18566511 MazzForces C June 17, 2016, 9:38 p.m. OK Java 7 TESTS 104 343 14745600 1700
18635228 mkirsche C June 21, 2016, 6:48 p.m. OK Java 7 TESTS 105 358 17203200 1700
18628262 aldeebiano C June 21, 2016, 10:36 a.m. OK Java 7 TESTS 105 358 27340800 1700
18612427 coder_better C June 20, 2016, 10:29 a.m. OK Java 7 TESTS 105 373 62771200 1700
19038642 hama-du C July 12, 2016, 1:09 a.m. OK Java 8 TESTS 106 171 5017600 1700
25129983 Mihir_Gajera1 C March 1, 2017, 5:24 p.m. OK Java 8 TESTS 106 171 36454400 1700
19921784 ankurverma1994 C Aug. 17, 2016, 7:27 a.m. OK Java 8 TESTS 106 187 37785600 1700
54412872 chojh1222 C May 20, 2019, 10:58 a.m. OK Java 8 TESTS 106 202 24576000 1700
56684501 Dukkha C July 7, 2019, 8:59 p.m. OK Java 8 TESTS 106 217 24985600 1700
43496329 aman28rwt C Sept. 27, 2018, 2:51 p.m. OK Java 8 TESTS 106 218 16179200 1700
33261105 coderbond007 C Dec. 15, 2017, 10:51 a.m. OK Java 8 TESTS 106 218 28774400 1700
48067852 weird_penguin C Jan. 7, 2019, 7:22 p.m. OK Java 8 TESTS 106 218 34201600 1700
39082959 prabhat236218 C June 10, 2018, 4:24 a.m. OK Java 8 TESTS 106 218 116224000 1700
35517089 In_The_Name_Of_Love C Feb. 20, 2018, 9:37 a.m. OK Java 8 TESTS 106 233 28262400 1700
27479179 as12 C June 1, 2017, 6:56 a.m. OK JavaScript TESTS 106 202 26316800 1700
27477388 as12 C June 1, 2017, 4:40 a.m. OK JavaScript TESTS 106 264 40448000 1700
27476144 as12 C June 1, 2017, 1:53 a.m. OK JavaScript TESTS 106 514 41164800 1700
21872399 og.kostya C Oct. 29, 2016, 1:13 p.m. OK MS C# TESTS 106 109 12492800 1700
18643716 DigitalArtistKz C June 22, 2016, 9:19 a.m. OK MS C# TESTS 105 405 30208000 1700
24007122 pomjuice C Jan. 21, 2017, 9:13 a.m. OK MS C# TESTS 106 436 38195200 1700
25360687 vjudge1 C March 9, 2017, 1:17 p.m. OK MS C++ TESTS 106 62 7680000 1700
57446980 vjudge2 C July 21, 2019, 8:31 a.m. OK MS C++ TESTS 106 62 7987200 1700
25344718 vjudge3 C March 8, 2017, 3:44 p.m. OK MS C++ TESTS 106 62 11264000 1700
57874474 vjudge3 C July 28, 2019, 4:19 a.m. OK MS C++ TESTS 106 62 14438400 1700
53324092 vjudge1 C April 26, 2019, 2:33 p.m. OK MS C++ TESTS 106 62 17612800 1700
20497189 sunmoyi C Sept. 10, 2016, 12:36 p.m. OK MS C++ TESTS 106 62 32768000 1700
57444814 vjudge2 C July 21, 2019, 7:54 a.m. OK MS C++ TESTS 106 77 7168000 1700
57456020 vjudge5 C July 21, 2019, 11:39 a.m. OK MS C++ TESTS 106 77 8396800 1700
65481723 vjudge4 C Nov. 21, 2019, 11:53 a.m. OK MS C++ TESTS 106 77 9625600 1700
25344085 siyutt C March 8, 2017, 3:08 p.m. OK MS C++ TESTS 106 77 11264000 1700
62309703 vjudge4 C Oct. 10, 2019, 1:36 p.m. OK MS C++ 2017 TESTS 106 108 7987200 1700
57449592 vjudge2 C July 21, 2019, 9:18 a.m. OK MS C++ 2017 TESTS 106 109 21401600 1700
61438233 CtrlAlt C Sept. 28, 2019, 5:33 p.m. OK MS C++ 2017 TESTS 106 343 13619200 1700
57467046 vjudge2 C July 21, 2019, 4:02 p.m. OK MS C++ 2017 TESTS 106 468 11776000 1700
18600497 Darooha C June 19, 2016, 2:57 p.m. OK Ocaml TESTS 105 171 16384000 1700
33372290 shubhu1596 wewakeprasad FatherofBenoni C Dec. 18, 2017, 8:17 a.m. OK PyPy 2 TESTS 106 467 33075200 1700
32994188 xiaowuc1 C Dec. 7, 2017, 7:23 a.m. OK PyPy 2 TESTS 106 468 32665600 1700
32994212 xiaowuc1 C Dec. 7, 2017, 7:24 a.m. OK PyPy 2 TESTS 106 483 33484800 1700
22946455 Yash_ C Dec. 14, 2016, 10:52 a.m. OK PyPy 2 TESTS 106 530 12902400 1700
18569620 dpforest C June 18, 2016, 2:27 a.m. OK PyPy 2 TESTS 104 763 27136000 1700
20371252 sknaht C Sept. 3, 2016, 9:48 p.m. OK Python 2 TESTS 106 483 25088000 1700
54987674 anshuman16423 C June 2, 2019, 4:38 p.m. OK Python 2 TESTS 106 499 19763200 1700
22667268 abhigupta4 C Dec. 2, 2016, 11:36 p.m. OK Python 2 TESTS 106 530 19968000 1700
18569611 dpforest C June 18, 2016, 2:26 a.m. OK Python 2 TESTS 104 592 21401600 1700
18564197 osev C June 17, 2016, 6:33 p.m. OK Python 2 TESTS 104 592 28876800 1700
26133544 ffosilva C April 5, 2017, 12:14 a.m. OK Python 2 TESTS 106 639 27955200 1700
19215634 yuto C July 18, 2016, 3:31 p.m. OK Python 2 TESTS 106 779 55500800 1700
18635589 ololo.jfhs C June 21, 2016, 7:20 p.m. OK Python 2 TESTS 105 997 31232000 1700
25301612 shahed_shd C March 6, 2017, 7:51 p.m. OK Python 3 TESTS 106 405 41164800 1700
25135686 vjudge2 C March 1, 2017, 8:38 p.m. OK Python 3 TESTS 106 405 41267200 1700
26133973 LHAMA C April 5, 2017, 1:20 a.m. OK Python 3 TESTS 106 421 41472000 1700
18575989 Punter C June 18, 2016, 9:44 a.m. OK Python 3 TESTS 105 499 20889600 1700
18584591 Andfive C June 18, 2016, 5:50 p.m. OK Python 3 TESTS 105 529 23040000 1700
18584707 Andfive C June 18, 2016, 5:57 p.m. OK Python 3 TESTS 105 530 23552000 1700
54708432 Aidos C May 27, 2019, 6:29 a.m. OK Python 3 TESTS 106 576 20992000 1700
19033726 bazyar.sepehr C July 11, 2016, 4:10 p.m. OK Python 3 TESTS 106 639 29491200 1700
18567657 whiord C June 17, 2016, 11:14 p.m. OK Python 3 TESTS 104 670 26214400 1700
18578760 UnusedFever C June 18, 2016, 12:14 p.m. OK Python 3 TESTS 105 701 29696000 1700
19055127 netoctone C July 12, 2016, 4:42 p.m. OK Ruby TESTS 106 763 54067200 1700
18566178 wrick C June 17, 2016, 9:21 p.m. OK Scala TESTS 104 888 45977600 1700

remove filters

Back to search problems