Codeforces Round 895 (Div. 3)

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
1872 Codeforces Round 895 (Div. 3) FINISHED False 8100 43082663 Sept. 7, 2023, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 6572 ) F Selling a Menagerie PROGRAMMING dfs and similar ds graphs implementation math

B'You are the owner of a menagerie consisting of n animals numbered from 1 to n . However, maintaining the menagerie is quite expensive, so you have decided to sell it! It is known that each animal is afraid of exactly one other animal. More precisely, animal i is afraid of animal a_i ( a_i neq i ). Also, the cost of each animal is known, for animal i it is equal to c_i . You will sell all your animals in some fixed order. Formally, you will need to choose some permutation ^ dagger p_1, p_2, ldots, p_n , and sell animal p_1 first, then animal p_2 , and so on, selling animal p_n last. When you sell animal i , there are two possible outcomes: Your task is to choose the order of selling the animals in order to maximize the total profit. For example, if a = [3, 4, 4, 1, 3] , c = [3, 4, 5, 6, 7] , and the permutation you choose is [4, 2, 5, 1, 3] , then: Your total profit, with this choice of permutation, is 12 + 4 + 14 + 6 + 5 = 41 . Note that 41 is not the maximum possible profit in this example. ^ dagger A permutation of length n is an array consisting of n distinct integers from 1 to n in any order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation ( 2 appears twice in the array) and [1,3,4] is also not a permutation ( n=3 , but 4 is present in the array). The first line of the input contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases. Then follow the descriptions of the test cases. The first line of each test case description contains an integer n ( 2 <= n <= 10^5 ) -- the number of animals. The second line of the test case description contains n integers a_1, a_2, ... , a_n ( 1 <= a_i <= n , a_i neq i ) -- a_i means the index of the animal that animal i is afraid of. The third line of'...

Tutorials

Codeforces Round 895 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
222391583 lAMaLOSER F Sept. 8, 2023, 4:07 a.m. OK C# 10 TESTS 33 498 41881600
222392500 Redpo F Sept. 8, 2023, 4:19 a.m. OK Clang++20 Diagnostics TESTS 33 1871 14131200
222385323 rickyxrc F Sept. 8, 2023, 2:21 a.m. OK GNU C++14 TESTS 33 62 2150400
222386629 ptilopsis- F Sept. 8, 2023, 2:45 a.m. OK GNU C++14 TESTS 33 62 3072000
222376940 Wegz F Sept. 7, 2023, 11:03 p.m. OK GNU C++14 TESTS 33 77 2969600
222369947 kaarthik_raja F Sept. 7, 2023, 8:44 p.m. OK GNU C++14 TESTS 33 78 2355200
222369484 karansrivastava F Sept. 7, 2023, 8:37 p.m. OK GNU C++14 TESTS 33 78 2457600
222377021 Wegz F Sept. 7, 2023, 11:05 p.m. OK GNU C++14 TESTS 33 78 2969600
222376830 Wegz F Sept. 7, 2023, 11 p.m. OK GNU C++14 TESTS 33 78 2969600
222369510 dushki F Sept. 7, 2023, 8:37 p.m. OK GNU C++14 TESTS 33 78 3174400
222397183 apiboy F Sept. 8, 2023, 5:11 a.m. OK GNU C++14 TESTS 33 78 4096000
222376753 Wegz F Sept. 7, 2023, 10:57 p.m. OK GNU C++14 TESTS 33 78 6041600
222354511 lunchbox F Sept. 7, 2023, 5:52 p.m. OK GNU C++17 TESTS 33 46 9625600
222354125 FzArK F Sept. 7, 2023, 5:48 p.m. OK GNU C++17 TESTS 33 77 1740800
222350397 jlallas384 F Sept. 7, 2023, 5:22 p.m. OK GNU C++17 TESTS 33 77 2662400
222380415 conexposys F Sept. 8, 2023, 12:35 a.m. OK GNU C++17 TESTS 33 77 3072000
222397307 xbai F Sept. 8, 2023, 5:13 a.m. OK GNU C++17 TESTS 33 77 3584000
222364405 jainaditya8464 F Sept. 7, 2023, 7:31 p.m. OK GNU C++17 TESTS 33 77 3686400
222371333 Sellihca F Sept. 7, 2023, 9:08 p.m. OK GNU C++17 TESTS 33 77 4300800
222379459 conexposys F Sept. 8, 2023, 12:11 a.m. OK GNU C++17 TESTS 33 77 5632000
222368405 zys111 F Sept. 7, 2023, 8:22 p.m. OK GNU C++17 TESTS 33 78 1638400
222375966 ronit26 F Sept. 7, 2023, 10:37 p.m. OK GNU C++17 TESTS 33 78 1740800
222394080 XH_v F Sept. 8, 2023, 4:36 a.m. OK GNU C++17 (64) TESTS 33 46 2764800
222350753 TrendBattles F Sept. 7, 2023, 5:24 p.m. OK GNU C++17 (64) TESTS 33 62 1740800
222349208 TrendBattles F Sept. 7, 2023, 5:16 p.m. OK GNU C++17 (64) TESTS 33 62 1740800
222373127 Linoed F Sept. 7, 2023, 9:40 p.m. OK GNU C++17 (64) TESTS 33 62 1945600
222367995 enslaved F Sept. 7, 2023, 8:16 p.m. OK GNU C++17 (64) TESTS 33 62 2457600
222385715 EotUL8d7 F Sept. 8, 2023, 2:28 a.m. OK GNU C++17 (64) TESTS 33 62 2764800
222384980 LXH-cat F Sept. 8, 2023, 2:15 a.m. OK GNU C++17 (64) TESTS 33 62 2764800
222383239 cheng1202 F Sept. 8, 2023, 1:41 a.m. OK GNU C++17 (64) TESTS 33 62 3379200
222401182 Higuchi F Sept. 8, 2023, 5:59 a.m. OK GNU C++17 (64) TESTS 33 62 3481600
222385610 fexla F Sept. 8, 2023, 2:26 a.m. OK GNU C++17 (64) TESTS 33 62 3584000
222363060 Throckmorton F Sept. 7, 2023, 7:15 p.m. OK GNU C++20 (64) TESTS 33 46 1228800
222386855 oloy F Sept. 8, 2023, 2:49 a.m. OK GNU C++20 (64) TESTS 33 46 1638400
222380823 1RONMAN F Sept. 8, 2023, 12:46 a.m. OK GNU C++20 (64) TESTS 33 46 1638400
222364147 cont2 F Sept. 7, 2023, 7:28 p.m. OK GNU C++20 (64) TESTS 33 46 1638400
222347815 Heliumeow F Sept. 7, 2023, 5:09 p.m. OK GNU C++20 (64) TESTS 33 46 1638400
222374462 Tansho F Sept. 7, 2023, 10:05 p.m. OK GNU C++20 (64) TESTS 33 46 1740800
222371595 Java F Sept. 7, 2023, 9:13 p.m. OK GNU C++20 (64) TESTS 33 46 1945600
222400313 uestc_chicken F Sept. 8, 2023, 5:50 a.m. OK GNU C++20 (64) TESTS 33 46 2048000
222360059 gjain_7 F Sept. 7, 2023, 6:41 p.m. OK GNU C++20 (64) TESTS 33 46 2048000
222391067 ntuanvu89 F Sept. 8, 2023, 3:59 a.m. OK GNU C++20 (64) TESTS 33 46 2252800
222358100 singhharman F Sept. 7, 2023, 6:22 p.m. OK Java 11 TESTS 33 248 0
222358051 Harman_Singh F Sept. 7, 2023, 6:22 p.m. OK Java 11 TESTS 33 248 0
222401447 ggghg F Sept. 8, 2023, 6:01 a.m. OK Java 11 TESTS 33 296 20377600
222390888 WORTH F Sept. 8, 2023, 3:56 a.m. OK Java 11 TESTS 33 358 17408000
222387211 Mamimi F Sept. 8, 2023, 2:55 a.m. OK Java 17 TESTS 33 311 3481600
222358656 dzhi F Sept. 7, 2023, 6:27 p.m. OK Java 17 TESTS 33 326 7987200
222348555 kartik83789 F Sept. 7, 2023, 5:12 p.m. OK Java 8 TESTS 33 826 13312000
222387227 linxiaotian F Sept. 8, 2023, 2:55 a.m. OK Kotlin 1.6 TESTS 33 342 13004800
222385994 zsn1434 F Sept. 8, 2023, 2:33 a.m. OK MS C++ 2017 TESTS 33 280 11264000
222390156 biltharesatyendra F Sept. 8, 2023, 3:44 a.m. OK PyPy 2 TESTS 33 514 13209600
222359427 xyxoro F Sept. 7, 2023, 6:34 p.m. OK PyPy 3 TESTS 33 389 30412800
222354728 alexwice F Sept. 7, 2023, 5:53 p.m. OK PyPy 3-64 TESTS 33 202 20275200
222383844 gardengnome F Sept. 8, 2023, 1:53 a.m. OK PyPy 3-64 TESTS 33 202 20582400
222372592 denilb F Sept. 7, 2023, 9:30 p.m. OK PyPy 3-64 TESTS 33 202 24678400
222353047 abcsumits F Sept. 7, 2023, 5:40 p.m. OK PyPy 3-64 TESTS 33 218 24780800
222353961 Ana_naS F Sept. 7, 2023, 5:47 p.m. OK PyPy 3-64 TESTS 33 233 24473600
222364489 Chimpanzee F Sept. 7, 2023, 7:32 p.m. OK PyPy 3-64 TESTS 33 248 22323200
222390773 RetiredNanfeng F Sept. 8, 2023, 3:54 a.m. OK PyPy 3-64 TESTS 33 248 25702400
222349310 MenaceJn F Sept. 7, 2023, 5:16 p.m. OK PyPy 3-64 TESTS 33 265 19968000
222348765 RobinFromTheHood F Sept. 7, 2023, 5:13 p.m. OK PyPy 3-64 TESTS 33 265 21401600
222346944 denilb F Sept. 7, 2023, 5:05 p.m. OK PyPy 3-64 TESTS 33 295 24678400
222387986 2110030158_Nithin F Sept. 8, 2023, 3:09 a.m. OK Python 3 TESTS 33 264 27545600
222367706 rajanlawar_24 F Sept. 7, 2023, 8:12 p.m. OK Python 3 TESTS 33 265 27443200
222351370 2110030033 F Sept. 7, 2023, 5:29 p.m. OK Python 3 TESTS 33 280 27545600
222389246 wangxs F Sept. 8, 2023, 3:30 a.m. OK Python 3 TESTS 33 311 21606400
222371888 vibhorsaxena000 F Sept. 7, 2023, 9:18 p.m. OK Python 3 TESTS 33 311 21708800
222361498 BananaHead F Sept. 7, 2023, 6:57 p.m. OK Python 3 TESTS 33 327 19148800
222362879 sevlll777 F Sept. 7, 2023, 7:13 p.m. OK Python 3 TESTS 33 343 21708800
222359775 Vishnu_Actual F Sept. 7, 2023, 6:38 p.m. OK Python 3 TESTS 33 842 43110400
222354179 utoppia F Sept. 7, 2023, 5:49 p.m. OK Python 3 TESTS 33 1091 24780800

remove filters

Back to search problems