Codeforces Round 942 (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
1967 Codeforces Round 942 (Div. 1) FINISHED False 9000 22692263 April 30, 2024, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 12973 ) A Permutation Counting PROGRAMMING binary search greedy implementation math sortings 1400

B"You have some cards. An integer between 1 and n is written on each card: specifically, for each i from 1 to n , you have a_i cards which have the number i written on them. There is also a shop which contains unlimited cards of each type. You have k coins, so you can buy k new cards in total, and the cards you buy can contain any integer between 1 and n . After buying the new cards, you rearrange all your cards in a line. The score of a rearrangement is the number of (contiguous) subarrays of length n which are a permutation of [1, 2, ldots, n] . What's the maximum score you can get? Each test contains multiple test cases. The first line contains the number of test cases t (1 <= t <= 100) . The description of the test cases follows. The first line of each test case contains two integers n , k ( 1 <= n <= 2 cdot 10^5 , 0 <= k <= 10^{12} ) -- the number of distinct types of cards and the number of coins. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^{12} ) -- the number of cards of type i you have at the beginning. It is guaranteed that the sum of n over all test cases does not exceed 5 cdot 10^5 . For each test case, output a single line containing an integer: the maximum score you can get. In the first test case, the final (and only) array we can get is [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] (including 11 single 1 s), which contains 11 subarrays consisting of a permutation of [1] . In the second test case, we can buy 0 cards of type 1 and 4 cards of type 2 , and then we rearrange the cards as following: [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2] . There are 8 subarrays equal to [1, 2] and 7 subarrays equal to [2, 1] , which make a total of 15 subarrays which are a permutation of [1"...

Tutorials

Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
258881230 mban259 A April 30, 2024, 3 p.m. OK C# 10 TESTS 18 265 48742400 1400
259433238 HHYAndy_AK_IOI A May 4, 2024, 1:12 a.m. OK C++14 (GCC 6-32) TESTS 31 93 1740800 1400
259433357 luogu_bot3 A May 4, 2024, 1:15 a.m. OK C++14 (GCC 6-32) TESTS 31 124 1740800 1400
258874105 Max_s_xaM A April 30, 2024, 2:49 p.m. OK C++14 (GCC 6-32) TESTS 18 124 3686400 1400
259995021 EulerXA A May 8, 2024, 12:07 p.m. OK C++14 (GCC 6-32) TESTS 31 124 19251200 1400
258948298 chenhongrui A May 1, 2024, 12:18 a.m. OK C++14 (GCC 6-32) TESTS 18 156 1638400 1400
258932926 sammyuri A April 30, 2024, 6:58 p.m. OK C++14 (GCC 6-32) TESTS 18 171 0 1400
258875663 mcfr A April 30, 2024, 2:51 p.m. OK C++14 (GCC 6-32) TESTS 18 171 0 1400
258869514 lamduybao03 A April 30, 2024, 2:44 p.m. OK C++14 (GCC 6-32) TESTS 18 171 0 1400
258874570 ppltn A April 30, 2024, 2:50 p.m. OK C++14 (GCC 6-32) TESTS 18 171 1126400 1400
258882239 eggegg185 A April 30, 2024, 3:02 p.m. OK C++14 (GCC 6-32) TESTS 18 171 1638400 1400
258874052 a999999 A April 30, 2024, 2:49 p.m. OK C++17 (GCC 7-32) TESTS 18 109 3481600 1400
258877625 WaterSL A April 30, 2024, 2:54 p.m. OK C++17 (GCC 7-32) TESTS 18 124 5836800 1400
258873330 ImmortaLimit A April 30, 2024, 2:48 p.m. OK C++17 (GCC 7-32) TESTS 18 139 19251200 1400
258906140 ajj A April 30, 2024, 4:04 p.m. OK C++17 (GCC 7-32) TESTS 18 155 0 1400
258877404 RigBuhBuh A April 30, 2024, 2:54 p.m. OK C++17 (GCC 7-32) TESTS 18 155 0 1400
258880847 PaiDouLong A April 30, 2024, 3 p.m. OK C++17 (GCC 7-32) TESTS 18 156 0 1400
258876571 AbdoSa3d A April 30, 2024, 2:53 p.m. OK C++17 (GCC 7-32) TESTS 18 156 0 1400
258903369 AndrewSeven A April 30, 2024, 3:54 p.m. OK C++17 (GCC 7-32) TESTS 18 156 1638400 1400
258875745 Jie-XuSheng A April 30, 2024, 2:52 p.m. OK C++17 (GCC 7-32) TESTS 18 156 1638400 1400
258888215 oceeff A April 30, 2024, 3:14 p.m. OK C++17 (GCC 7-32) TESTS 18 156 3686400 1400
258874278 Sulfox A April 30, 2024, 2:49 p.m. OK C++20 (GCC 13-64) TESTS 18 78 3174400 1400
258866110 20333333333 A April 30, 2024, 2:40 p.m. OK C++20 (GCC 13-64) TESTS 18 78 3686400 1400
258865348 QAQAutoMaton A April 30, 2024, 2:39 p.m. OK C++20 (GCC 13-64) TESTS 18 78 5836800 1400
258867658 shiomusubi496 A April 30, 2024, 2:42 p.m. OK C++20 (GCC 13-64) TESTS 18 93 0 1400
258980884 Golem__ A May 1, 2024, 7:55 a.m. OK C++20 (GCC 13-64) TESTS 19 93 1843200 1400
258871026 wcdr A April 30, 2024, 2:45 p.m. OK C++20 (GCC 13-64) TESTS 18 93 1843200 1400
258866694 cmk666 A April 30, 2024, 2:41 p.m. OK C++20 (GCC 13-64) TESTS 18 93 2150400 1400
260749824 Haneochi A May 13, 2024, 6:29 a.m. OK C++20 (GCC 13-64) TESTS 31 108 10035200 1400
258961100 Dan13llljws A May 1, 2024, 4:28 a.m. OK C++20 (GCC 13-64) TESTS 19 109 0 1400
258867606 I_Love_Diar_Narumov A April 30, 2024, 2:42 p.m. OK C++20 (GCC 13-64) TESTS 18 109 0 1400
258873839 Gassa A April 30, 2024, 2:49 p.m. OK D TESTS 18 390 26726400 1400
258876809 hos.lyric A April 30, 2024, 2:53 p.m. OK D TESTS 18 484 20889600 1400
262085075 AbNv069 A May 22, 2024, 4:20 a.m. OK GNU C11 TESTS 31 218 3379200 1400
261105032 anirudh2005 A May 15, 2024, 9:08 p.m. OK GNU C11 TESTS 31 249 1638400 1400
258873954 chro4896 A April 30, 2024, 2:49 p.m. OK GNU C11 TESTS 18 280 1740800 1400
263083828 nguyenquocthao00 A May 29, 2024, 4:04 a.m. OK Go TESTS 31 124 13312000 1400
258991320 nguyenquocthao00 A May 1, 2024, 9:44 a.m. OK Go TESTS 19 140 13209600 1400
259288322 nguyenquocthao00 A May 3, 2024, 2:26 a.m. OK Go TESTS 31 156 13209600 1400
260489007 nguyenquocthao00 A May 11, 2024, 5:49 a.m. OK Go TESTS 31 171 13209600 1400
261429276 stolis A May 17, 2024, 7:40 p.m. OK Java 21 TESTS 31 343 1024000 1400
258886478 profchi A April 30, 2024, 3:10 p.m. OK Java 21 TESTS 18 390 6656000 1400
258881641 MaxBuzz A April 30, 2024, 3:01 p.m. OK Java 21 TESTS 18 421 6553600 1400
258878652 saptarshi1729 A April 30, 2024, 2:56 p.m. OK Java 21 TESTS 18 452 36966400 1400
262270546 rishit164 A May 23, 2024, 2:10 p.m. OK Java 21 TESTS 31 468 7577600 1400
258873292 ffaann A April 30, 2024, 2:48 p.m. OK Java 21 TESTS 18 483 7168000 1400
258885250 DarLam A April 30, 2024, 3:08 p.m. OK Java 21 TESTS 18 499 5529600 1400
258871771 FierteDeCeylan A April 30, 2024, 2:46 p.m. OK Java 21 TESTS 18 514 819200 1400
261686731 kunjbhuva89 A May 19, 2024, 5:41 p.m. OK Java 21 TESTS 31 562 88371200 1400
259489746 sagbis A May 4, 2024, 10:03 a.m. OK Java 21 TESTS 31 624 7475200 1400
258875463 cc4414 A April 30, 2024, 2:51 p.m. OK Java 8 TESTS 18 296 15564800 1400
260167135 Nagendravarma A May 9, 2024, 6:49 p.m. OK Java 8 TESTS 31 406 17203200 1400
260898893 formidablechief27 A May 14, 2024, 8:41 a.m. OK Java 8 TESTS 31 421 99840000 1400
258871183 MagentaCobra A April 30, 2024, 2:46 p.m. OK Java 8 TESTS 18 468 3993600 1400
259568879 chinatest A May 4, 2024, 11:44 p.m. OK Java 8 TESTS 31 1030 0 1400
259079842 kasiru_69 A May 2, 2024, 4:35 a.m. OK Java 8 TESTS 31 1124 13824000 1400
261303707 assassin_Death A May 17, 2024, 9:08 a.m. OK Java 8 TESTS 31 1156 0 1400
259087639 Somcodes A May 2, 2024, 6:18 a.m. OK Java 8 TESTS 31 1249 0 1400
259121544 kasiru_69 A May 2, 2024, 12:45 p.m. OK Java 8 TESTS 31 1405 13824000 1400
258866087 bruhopen A April 30, 2024, 2:40 p.m. OK Kotlin 1.9 TESTS 18 467 1331200 1400
258926896 wangchaohui A April 30, 2024, 5:53 p.m. OK Kotlin 1.9 TESTS 18 656 15257600 1400
258870842 Tlatoani A April 30, 2024, 2:45 p.m. OK Kotlin 1.9 TESTS 18 703 23040000 1400
258988058 __rose A May 1, 2024, 9:10 a.m. OK PyPy 3 TESTS 19 1327 28672000 1400
260176228 Alexithy A May 9, 2024, 8:28 p.m. OK PyPy 3 TESTS 31 1546 31232000 1400
263014416 xxx.ego A May 28, 2024, 1:03 p.m. OK PyPy 3 TESTS 31 1624 31846400 1400
258928480 cybsbbb A April 30, 2024, 6:06 p.m. OK PyPy 3-64 TESTS 18 234 31846400 1400
258874572 Alex239 A April 30, 2024, 2:50 p.m. OK PyPy 3-64 TESTS 18 264 29388800 1400
258876017 Vitaly503 A April 30, 2024, 2:52 p.m. OK PyPy 3-64 TESTS 18 265 30822400 1400
258929563 kwoncycle A April 30, 2024, 6:18 p.m. OK PyPy 3-64 TESTS 18 265 34713600 1400
259003348 voldemort__baba A May 1, 2024, 11:57 a.m. OK PyPy 3-64 TESTS 19 265 35020800 1400
258875116 strashila A April 30, 2024, 2:51 p.m. OK PyPy 3-64 TESTS 18 280 31539200 1400
259013729 SoonOOv A May 1, 2024, 1:41 p.m. OK PyPy 3-64 TESTS 27 281 23654400 1400
258928584 cybsbbb A April 30, 2024, 6:07 p.m. OK PyPy 3-64 TESTS 18 281 32256000 1400
258877016 shade34 A April 30, 2024, 2:53 p.m. OK PyPy 3-64 TESTS 18 281 33996800 1400
258875821 chmpro A April 30, 2024, 2:52 p.m. OK PyPy 3-64 TESTS 18 281 34099200 1400
258929646 Rogue_Ningen A April 30, 2024, 6:18 p.m. OK Python 3 TESTS 18 389 27648000 1400
258979856 makaka_2012 A May 1, 2024, 7:46 a.m. OK Python 3 TESTS 19 437 28160000 1400
258938003 bigdamdam A April 30, 2024, 8:12 p.m. OK Python 3 TESTS 18 437 34201600 1400
258924834 OLOGY A April 30, 2024, 5:39 p.m. OK Python 3 TESTS 18 499 28262400 1400
260000471 timiss A May 8, 2024, 12:46 p.m. OK Python 3 TESTS 31 546 28160000 1400
259364523 Roopa_003 A May 3, 2024, 1:37 p.m. OK Python 3 TESTS 31 562 28160000 1400
260159934 2210030287 A May 9, 2024, 5:37 p.m. OK Python 3 TESTS 31 578 28262400 1400
260158883 2200033007_KLU A May 9, 2024, 5:28 p.m. OK Python 3 TESTS 31 578 28262400 1400
259120188 julia.gorbacheva A May 2, 2024, 12:33 p.m. OK Python 3 TESTS 31 592 28262400 1400
261564924 CodeArmy A May 18, 2024, 5:38 p.m. OK Python 3 TESTS 31 609 28160000 1400
258958757 BetterThanNobita A May 1, 2024, 3:52 a.m. OK Rust 2021 TESTS 19 78 0 1400
258939459 n685 A April 30, 2024, 8:36 p.m. OK Rust 2021 TESTS 18 78 4198400 1400
260864140 Svlad_Cjelli A May 14, 2024, 12:46 a.m. OK Rust 2021 TESTS 31 108 4300800 1400
258868505 qwerty787788 A April 30, 2024, 2:43 p.m. OK Rust 2021 TESTS 18 156 0 1400
259020108 niyaznigmatul A May 1, 2024, 2:40 p.m. OK Rust 2021 TESTS 30 249 0 1400

remove filters

Back to search problems