Codeforces Round 896 (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
1868 Codeforces Round 896 (Div. 1) FINISHED False 9000 37468499 Sept. 10, 2023, 2:05 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 2428 ) B2 Candy Party (Hard Version) PROGRAMMING bitmasks constructive algorithms dp graphs greedy implementation math

B'This is the hard version of the problem. The only difference is that in this version everyone must give candies to no more than one person and receive candies from no more than one person. Note that a submission cannot pass both versions of the problem at the same time. You can make hacks only if both versions of the problem are solved. After Zhongkao examination, Daniel and his friends are going to have a party. Everyone will come with some candies. There will be n people at the party. Initially, the i -th person has a_i candies. During the party, they will swap their candies. To do this, they will line up in an arbitrary order and everyone will do the following no more than once: Daniel likes fairness, so he will be happy if and only if everyone receives candies from no more than one person. Meanwhile, his friend Tom likes average, so he will be happy if and only if all the people have the same number of candies after all swaps. Determine whether there exists a way to swap candies, so that both Daniel and Tom will be happy after the swaps. The first line of input contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 2 <= n <= 2 cdot 10^5 ) -- the number of people at the party. The second line of each test case contains n integers a_1,a_2, ldots,a_n ( 1 <= a_i <= 10^9 ) -- the number of candies each person has. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, print "Yes" (without quotes) if exists a way to swap candies to make both Daniel and Tom happy, and print "No" (without quotes) otherwise. You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses. In the first test case, the second person gives 1 candy to th'...

Tutorials

Codeforces Round 896 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
222778297 mban259 B2 Sept. 10, 2023, 3:38 p.m. OK C# 10 TESTS 57 186 22118400
222841904 KumaTachiRen B2 Sept. 11, 2023, 1:28 a.m. OK C# 8 TESTS 57 186 4505600
222748678 hos.lyric B2 Sept. 10, 2023, 2:41 p.m. OK D TESTS 57 93 13516800
222754349 Gassa B2 Sept. 10, 2023, 2:50 p.m. OK D TESTS 57 249 13721600
222773269 Leasier B2 Sept. 10, 2023, 3:27 p.m. OK GNU C++14 TESTS 57 61 4812800
222839953 XZC__Bobby B2 Sept. 11, 2023, 12:43 a.m. OK GNU C++14 TESTS 57 62 819200
222768877 MCPlayer542 B2 Sept. 10, 2023, 3:17 p.m. OK GNU C++14 TESTS 57 62 819200
222788676 Lucky-Xiang B2 Sept. 10, 2023, 3:59 p.m. OK GNU C++14 TESTS 57 62 921600
222773686 Haa B2 Sept. 10, 2023, 3:28 p.m. OK GNU C++14 TESTS 57 62 1638400
222772682 Gorou B2 Sept. 10, 2023, 3:26 p.m. OK GNU C++14 TESTS 57 62 1843200
222857530 pring B2 Sept. 11, 2023, 6:01 a.m. OK GNU C++14 TESTS 57 62 6553600
222783509 KevinYao B2 Sept. 10, 2023, 3:50 p.m. OK GNU C++14 TESTS 57 77 819200
222760207 yeminghan B2 Sept. 10, 2023, 3 p.m. OK GNU C++14 TESTS 57 77 819200
222755230 meteor_shower B2 Sept. 10, 2023, 2:52 p.m. OK GNU C++14 TESTS 57 77 819200
222841543 TeasingMaster B2 Sept. 11, 2023, 1:20 a.m. OK GNU C++17 TESTS 57 31 1843200
222848324 HaPpY1213 B2 Sept. 11, 2023, 3:38 a.m. OK GNU C++17 TESTS 57 62 819200
222841755 sha7dow B2 Sept. 11, 2023, 1:24 a.m. OK GNU C++17 TESTS 57 62 819200
222757143 leinad2 B2 Sept. 10, 2023, 2:55 p.m. OK GNU C++17 TESTS 57 62 819200
222846841 Tippy B2 Sept. 11, 2023, 3:09 a.m. OK GNU C++17 TESTS 57 62 1740800
222800218 Maezra6 B2 Sept. 10, 2023, 4:25 p.m. OK GNU C++17 TESTS 57 77 819200
222799557 batmend_kh B2 Sept. 10, 2023, 4:23 p.m. OK GNU C++17 TESTS 57 77 819200
222768373 chemthan B2 Sept. 10, 2023, 3:16 p.m. OK GNU C++17 TESTS 57 77 2048000
222849172 el3ctricstick B2 Sept. 11, 2023, 3:55 a.m. OK GNU C++17 TESTS 57 77 7987200
222845637 Spitfire_F_Mk_24 B2 Sept. 11, 2023, 2:44 a.m. OK GNU C++17 TESTS 57 78 819200
222760174 hydro-bot3 B2 Sept. 10, 2023, 3 p.m. OK GNU C++17 (64) TESTS 57 30 819200
222833840 enslaved B2 Sept. 10, 2023, 10 p.m. OK GNU C++17 (64) TESTS 57 46 819200
222773680 demian123 B2 Sept. 10, 2023, 3:28 p.m. OK GNU C++17 (64) TESTS 57 46 819200
222775990 SmolBrain B2 Sept. 10, 2023, 3:33 p.m. OK GNU C++17 (64) TESTS 57 46 1638400
222767207 EnEm B2 Sept. 10, 2023, 3:14 p.m. OK GNU C++17 (64) TESTS 57 46 1638400
222766647 natsugiri B2 Sept. 10, 2023, 3:13 p.m. OK GNU C++17 (64) TESTS 57 46 1638400
222744648 YamadaRyo B2 Sept. 10, 2023, 2:35 p.m. OK GNU C++17 (64) TESTS 57 46 1638400
222738390 Xylenox B2 Sept. 10, 2023, 2:25 p.m. OK GNU C++17 (64) TESTS 57 46 1638400
222847108 Flandre B2 Sept. 11, 2023, 3:14 a.m. OK GNU C++17 (64) TESTS 57 46 3993600
222823510 Giga_Cronos B2 Sept. 10, 2023, 7:25 p.m. OK GNU C++17 (64) TESTS 57 46 4812800
222750481 maspy B2 Sept. 10, 2023, 2:44 p.m. OK GNU C++20 (64) TESTS 57 15 1638400
222757855 shiomusubi496 B2 Sept. 10, 2023, 2:56 p.m. OK GNU C++20 (64) TESTS 57 31 1638400
222761267 cmk666 B2 Sept. 10, 2023, 3:02 p.m. OK GNU C++20 (64) TESTS 57 31 2867200
222850489 a757403 B2 Sept. 11, 2023, 4:18 a.m. OK GNU C++20 (64) TESTS 57 46 819200
222843352 Ckcyi B2 Sept. 11, 2023, 1:58 a.m. OK GNU C++20 (64) TESTS 57 46 819200
222812320 DiegoGarcia B2 Sept. 10, 2023, 5:46 p.m. OK GNU C++20 (64) TESTS 57 46 819200
222807601 treewave B2 Sept. 10, 2023, 5:16 p.m. OK GNU C++20 (64) TESTS 57 46 819200
222802452 HNO2 B2 Sept. 10, 2023, 4:30 p.m. OK GNU C++20 (64) TESTS 57 46 819200
222796724 int_jim B2 Sept. 10, 2023, 4:16 p.m. OK GNU C++20 (64) TESTS 57 46 819200
222790379 zse B2 Sept. 10, 2023, 4:01 p.m. OK GNU C++20 (64) TESTS 57 46 819200
222831464 Ste B2 Sept. 10, 2023, 9:12 p.m. OK Java 11 TESTS 57 249 0
222801194 profchi B2 Sept. 10, 2023, 4:27 p.m. OK Java 11 TESTS 57 311 8089600
222776387 lemon_codes B2 Sept. 10, 2023, 3:34 p.m. OK Java 17 TESTS 57 295 921600
222776659 golions B2 Sept. 10, 2023, 3:34 p.m. OK Java 8 TESTS 57 202 4198400
222794659 RMA-NB B2 Sept. 10, 2023, 4:11 p.m. OK Java 8 TESTS 57 467 3379200
222745123 FastFreeTask B2 Sept. 10, 2023, 2:35 p.m. OK Kotlin 1.6 TESTS 57 233 716800
222763660 SPD_9X2 B2 Sept. 10, 2023, 3:07 p.m. OK PyPy 3 TESTS 57 795 23142400
222773062 misorin B2 Sept. 10, 2023, 3:26 p.m. OK PyPy 3-64 TESTS 57 140 32358400
222751174 whatshisbucket B2 Sept. 10, 2023, 2:45 p.m. OK PyPy 3-64 TESTS 57 155 29081600
222788492 chinerist B2 Sept. 10, 2023, 3:59 p.m. OK PyPy 3-64 TESTS 57 218 31744000
222799803 thewaxmango B2 Sept. 10, 2023, 4:24 p.m. OK PyPy 3-64 TESTS 57 233 27852800
222802951 squishybanana04 B2 Sept. 10, 2023, 4:31 p.m. OK PyPy 3-64 TESTS 57 280 21299200
222778029 alexwice B2 Sept. 10, 2023, 3:37 p.m. OK PyPy 3-64 TESTS 57 280 29184000
222781182 conqueror_of_tourist B2 Sept. 10, 2023, 3:44 p.m. OK PyPy 3-64 TESTS 57 280 29286400
222766959 tamato B2 Sept. 10, 2023, 3:14 p.m. OK PyPy 3-64 TESTS 57 280 41779200
222751916 jatloe B2 Sept. 10, 2023, 2:46 p.m. OK PyPy 3-64 TESTS 57 295 43622400
222745577 bronze_coder B2 Sept. 10, 2023, 2:36 p.m. OK PyPy 3-64 TESTS 57 327 32870400
222760620 Jimanbanashi B2 Sept. 10, 2023, 3:01 p.m. OK Python 2 TESTS 57 296 11468800
222762282 shade34 B2 Sept. 10, 2023, 3:04 p.m. OK Python 3 TESTS 57 420 28160000
222850525 hunglomdom B2 Sept. 11, 2023, 4:18 a.m. OK Python 3 TESTS 57 483 28569600

remove filters

Back to search problems