Codeforces Round 530 (Div. 1)

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
1098 Codeforces Round 530 (Div. 1) FINISHED False 9000 190733087 Jan. 5, 2019, 4:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 8909 ) A Sum in the tree PROGRAMMING constructive algorithms dfs and similar greedy trees 1600

B"Mitya has a rooted tree with n vertices indexed from 1 to n , where the root has index 1 . Each vertex v initially had an integer number a_v ge 0 written on it. For every vertex v Mitya has computed s_v : the sum of all values written on the vertices on the path from vertex v to the root, as well as h_v -- the depth of vertex v , which denotes the number of vertices on the path from vertex v to the root. Clearly, s_1=a_1 and h_1=1 . Then Mitya erased all numbers a_v , and by accident he also erased all values s_v for vertices with even depth (vertices with even h_v ). Your task is to restore the values a_v for every vertex, or determine that Mitya made a mistake. In case there are multiple ways to restore the values, you're required to find one which minimizes the total sum of values a_v for all vertices in the tree. The first line contains one integer n -- the number of vertices in the tree ( 2 <= n <= 10^5 ). The following line contains integers p_2 , p_3 , ... p_n , where p_i stands for the parent of vertex with index i in the tree ( 1 <= p_i < i ). The last line contains integer values s_1 , s_2 , ..., s_n ( -1 <= s_v <= 10^9 ), where erased values are replaced by -1 . Output one integer -- the minimum total sum of all values a_v in the original tree, or -1 if such tree does not exist. "...

Tutorials

64331

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
48006186 hos.lyric A Jan. 5, 2019, 6:34 p.m. OK D TESTS 38 77 22528000 1600
47980123 fluffyowl A Jan. 5, 2019, 4:50 p.m. OK D TESTS 38 108 28057600 1600
48377430 seedkin A Jan. 14, 2019, 8:26 a.m. OK GNU C11 TESTS 38 46 819200 1600
48281218 Bramble A Jan. 12, 2019, 8:04 a.m. OK GNU C11 TESTS 38 46 2048000 1600
47979853 rainboy A Jan. 5, 2019, 4:49 p.m. OK GNU C11 TESTS 38 61 1228800 1600
50674240 Yznew A March 2, 2019, 8:29 a.m. OK GNU C11 TESTS 38 61 1638400 1600
49903741 geeyiiz A Feb. 14, 2019, 10:51 a.m. OK GNU C11 TESTS 38 62 9318400 1600
52597067 PresHerobrine A April 11, 2019, 9:43 a.m. OK GNU C++11 TESTS 38 31 819200 1600
49662780 luogu_bot3 A Feb. 9, 2019, 1:11 p.m. OK GNU C++11 TESTS 38 31 1228800 1600
59650333 YLWang A Aug. 29, 2019, 7:55 a.m. OK GNU C++11 TESTS 38 31 1638400 1600
50705093 luogu_bot2 A March 3, 2019, 3:03 a.m. OK GNU C++11 TESTS 38 31 1638400 1600
48376853 luogu_bot1 A Jan. 14, 2019, 8:06 a.m. OK GNU C++11 TESTS 38 31 1638400 1600
48045078 FizzyDavid A Jan. 7, 2019, 1:24 a.m. OK GNU C++11 TESTS 38 31 3072000 1600
48077893 EnjoyCallen A Jan. 8, 2019, 5:37 a.m. OK GNU C++11 TESTS 38 31 3686400 1600
48156840 Zechariah_2001 A Jan. 9, 2019, 5:33 p.m. OK GNU C++11 TESTS 38 31 3993600 1600
48056251 Dilute A Jan. 7, 2019, 12:27 p.m. OK GNU C++11 TESTS 38 31 3993600 1600
47975392 QAQAutoMaton A Jan. 5, 2019, 4:41 p.m. OK GNU C++11 TESTS 38 31 5836800 1600
49928473 _HYX_ A Feb. 15, 2019, 2:07 a.m. OK GNU C++14 TESTS 38 46 8601600 1600
48021953 tokitsukaze A Jan. 6, 2019, 6:24 a.m. OK GNU C++14 TESTS 38 46 12697600 1600
53996500 Lagrang3 A May 11, 2019, 2:53 p.m. OK GNU C++14 TESTS 38 61 5734400 1600
48566665 nnandi A Jan. 19, 2019, 9:56 a.m. OK GNU C++14 TESTS 38 61 8601600 1600
69397246 KasugaAyumu A Jan. 23, 2020, 6:54 a.m. OK GNU C++14 TESTS 38 61 10137600 1600
57339282 Rishabh_Bhaai4 A July 19, 2019, 5:40 p.m. OK GNU C++14 TESTS 38 61 10956800 1600
48012774 Linkus A Jan. 5, 2019, 8:25 p.m. OK GNU C++14 TESTS 38 61 11161600 1600
48028680 apiadu A Jan. 6, 2019, 10:53 a.m. OK GNU C++14 TESTS 38 61 11776000 1600
47979101 593119681 A Jan. 5, 2019, 4:48 p.m. OK GNU C++14 TESTS 38 62 921600 1600
48009223 kiwikiwi A Jan. 5, 2019, 6:53 p.m. OK GNU C++14 TESTS 38 62 1024000 1600
48953865 vjudge2 A Jan. 26, 2019, 3:01 a.m. OK GNU C++17 TESTS 38 31 4096000 1600
48953902 Adang A Jan. 26, 2019, 3:04 a.m. OK GNU C++17 TESTS 38 46 4096000 1600
47975524 whzzt A Jan. 5, 2019, 4:41 p.m. OK GNU C++17 TESTS 38 46 8192000 1600
47978740 IgorSmirnov A Jan. 5, 2019, 4:47 p.m. OK GNU C++17 TESTS 38 46 12390400 1600
57601841 khoa3101 A July 23, 2019, 4:08 p.m. OK GNU C++17 TESTS 38 61 819200 1600
51353833 luogu_bot1 A March 16, 2019, 2:10 a.m. OK GNU C++17 TESTS 38 61 921600 1600
48889161 anay2102 A Jan. 24, 2019, 1:27 p.m. OK GNU C++17 TESTS 38 61 4812800 1600
51868467 stratoes A March 26, 2019, 4:17 p.m. OK GNU C++17 TESTS 38 61 8601600 1600
47979775 Arpa A Jan. 5, 2019, 4:49 p.m. OK GNU C++17 TESTS 38 61 9318400 1600
48066151 Reayz A Jan. 7, 2019, 6:14 p.m. OK GNU C++17 TESTS 38 61 10547200 1600
48041413 MarcoSchaefer A Jan. 6, 2019, 7:42 p.m. OK Go TESTS 38 77 25600000 1600
48042195 MarcoSchaefer A Jan. 6, 2019, 8:36 p.m. OK Go TESTS 38 93 34611200 1600
48176911 davidguandev A Jan. 10, 2019, 10:09 a.m. OK Go TESTS 38 124 27648000 1600
48177495 davidguandev A Jan. 10, 2019, 10:28 a.m. OK Go TESTS 38 139 18739200 1600
48098956 kumarmonu0522 A Jan. 8, 2019, 6:54 p.m. OK Java 8 TESTS 38 124 0 1600
48093351 kumarmonu0522 A Jan. 8, 2019, 3:11 p.m. OK Java 8 TESTS 38 124 0 1600
47975812 mmaxio A Jan. 5, 2019, 4:42 p.m. OK Java 8 TESTS 38 124 0 1600
47974956 ilyakor A Jan. 5, 2019, 4:40 p.m. OK Java 8 TESTS 38 124 0 1600
48026805 qwerty787788 A Jan. 6, 2019, 9:37 a.m. OK Java 8 TESTS 38 140 0 1600
47994641 Dukkha A Jan. 5, 2019, 5:35 p.m. OK Java 8 TESTS 38 140 0 1600
47976739 uwi A Jan. 5, 2019, 4:44 p.m. OK Java 8 TESTS 38 140 0 1600
47978144 fetetriste A Jan. 5, 2019, 4:46 p.m. OK Java 8 TESTS 38 155 0 1600
48038040 Darth_Jar_Jar_Binks A Jan. 6, 2019, 5 p.m. OK Java 8 TESTS 38 155 0 1600
47977721 liymbear A Jan. 5, 2019, 4:45 p.m. OK Java 8 TESTS 38 155 0 1600
47985319 elizarov A Jan. 5, 2019, 5:03 p.m. OK Kotlin TESTS 38 280 7065600 1600
65490465 5AF1 A Nov. 21, 2019, 2:25 p.m. OK Kotlin TESTS 38 327 0 1600
54732645 Quang A May 28, 2019, 2:06 a.m. OK Kotlin TESTS 38 451 63590400 1600
48038014 BackendDeveloper A Jan. 6, 2019, 4:59 p.m. OK Kotlin TESTS 38 514 25702400 1600
56223474 og.kostya A June 28, 2019, 10:44 a.m. OK Mono C# TESTS 38 109 12083200 1600
47994218 chokudai A Jan. 5, 2019, 5:33 p.m. OK Mono C# TESTS 38 155 23347200 1600
47995043 riantkb A Jan. 5, 2019, 5:36 p.m. OK Mono C# TESTS 38 156 28160000 1600
50234144 JasonZZM A Feb. 20, 2019, 9:55 a.m. OK MS C++ TESTS 38 46 2048000 1600
49048060 vjudge2 A Jan. 27, 2019, 9:45 a.m. OK MS C++ TESTS 38 46 2252800 1600
49080896 vjudge1 A Jan. 28, 2019, 6:06 a.m. OK MS C++ TESTS 38 46 6451200 1600
49301860 vjudge5 A Feb. 1, 2019, 3:37 a.m. OK MS C++ TESTS 38 61 7270400 1600
49036758 vjudge4 A Jan. 27, 2019, 3:55 a.m. OK MS C++ TESTS 38 61 10035200 1600
49034907 vjudge2 A Jan. 27, 2019, 2:26 a.m. OK MS C++ TESTS 38 62 4403200 1600
49134810 vjudge4 A Jan. 29, 2019, 7:04 a.m. OK MS C++ TESTS 38 62 6348800 1600
47977648 LoneFox A Jan. 5, 2019, 4:45 p.m. OK MS C++ TESTS 38 93 8806400 1600
57602512 huynhdainhan242 A July 23, 2019, 4:25 p.m. OK MS C++ TESTS 38 139 6860800 1600
57593423 TDat A July 23, 2019, 1:03 p.m. OK MS C++ TESTS 38 140 1638400 1600
52064658 hld67890 A March 31, 2019, 4:28 a.m. OK MS C++ 2017 TESTS 38 77 11161600 1600
49876113 Programmer007 A Feb. 13, 2019, 3:56 p.m. OK MS C++ 2017 TESTS 38 93 7270400 1600
57600515 pltd24 A July 23, 2019, 3:36 p.m. OK MS C++ 2017 TESTS 38 156 819200 1600
57602704 NHNgoc A July 23, 2019, 4:31 p.m. OK MS C++ 2017 TESTS 38 156 1638400 1600
66315753 LinusTorvaldsFan A Dec. 5, 2019, 1:01 p.m. OK MS C++ 2017 TESTS 38 156 6451200 1600
57482643 KhanhMai2912 A July 22, 2019, 3:17 a.m. OK MS C++ 2017 TESTS 38 156 9728000 1600
60384776 Yanhui A Sept. 11, 2019, 11:01 a.m. OK MS C++ 2017 TESTS 38 171 4403200 1600
57509815 Quandoan A July 22, 2019, 1:21 p.m. OK MS C++ 2017 TESTS 38 171 4812800 1600
69676926 IPRIT A Jan. 28, 2020, 2:32 p.m. OK MS C++ 2017 TESTS 38 171 6860800 1600
57600359 18125105 A July 23, 2019, 3:32 p.m. OK MS C++ 2017 TESTS 38 171 7577600 1600
47994404 pajenegod A Jan. 5, 2019, 5:34 p.m. OK PyPy 2 TESTS 38 186 11161600 1600
49156702 soumyasarkar1998 A Jan. 29, 2019, 1:59 p.m. OK PyPy 2 TESTS 38 234 11673600 1600
48014338 c1729 A Jan. 5, 2019, 9:12 p.m. OK PyPy 2 TESTS 38 249 22323200 1600
47980388 astrom.lars A Jan. 5, 2019, 4:50 p.m. OK PyPy 2 TESTS 38 280 13107200 1600
48414946 bartek.brzoza A Jan. 15, 2019, 9:50 a.m. OK PyPy 3 TESTS 38 311 16793600 1600
54744908 MotaSanyal A May 28, 2019, 10:01 a.m. OK PyPy 3 TESTS 38 404 20992000 1600
48889447 max_hha A Jan. 24, 2019, 1:32 p.m. OK PyPy 3 TESTS 38 421 24064000 1600
47982421 nwi A Jan. 5, 2019, 4:55 p.m. OK Python 2 TESTS 38 295 6860800 1600
50309623 nealzane A Feb. 22, 2019, 8:34 a.m. OK Python 2 TESTS 38 358 10752000 1600
58239880 ssk497 A Aug. 3, 2019, 11:09 p.m. OK Python 2 TESTS 38 436 11878400 1600
48096990 bhavana4842 A Jan. 8, 2019, 5:30 p.m. OK Python 3 TESTS 38 249 8704000 1600
48780604 pedrofreire A Jan. 23, 2019, 6:40 a.m. OK Python 3 TESTS 38 327 13209600 1600
48062192 y.kemaev A Jan. 7, 2019, 3:59 p.m. OK Python 3 TESTS 38 342 14028800 1600
64462134 MinecraftFuns A Nov. 7, 2019, 10:44 a.m. OK Python 3 TESTS 38 358 13721600 1600
48018755 whatshisbucket A Jan. 6, 2019, 3:09 a.m. OK Python 3 TESTS 38 358 172748800 1600
48044716 enkokoko A Jan. 7, 2019, 12:34 a.m. OK Python 3 TESTS 38 374 12083200 1600
48016823 Bovniova A Jan. 6, 2019, 12:06 a.m. OK Python 3 TESTS 38 389 15974400 1600
62369399 Sevlll A Oct. 11, 2019, 2:51 p.m. OK Python 3 TESTS 38 468 30617600 1600
48162330 youness.amhaouch A Jan. 9, 2019, 8:23 p.m. OK Python 3 TESTS 38 608 28672000 1600
47982043 alpha_virginis A Jan. 5, 2019, 4:54 p.m. OK Rust TESTS 38 61 5120000 1600
49612804 AlexProk A Feb. 8, 2019, 3:23 a.m. OK Scala TESTS 38 748 107827200 1600

remove filters

Back to search problems