Codeforces Round 961 (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
1995 Codeforces Round 961 (Div. 2) FINISHED False 7200 10077899 July 23, 2024, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 8769 ) B2 Bouquet (Hard Version) PROGRAMMING binary search data structures greedy math sortings two pointers

B'This is the hard version of the problem. The only difference is that in this version, instead of listing the number of petals for each flower, the number of petals and the quantity of flowers in the store is set for all types of flowers. A girl is preparing for her birthday and wants to buy the most beautiful bouquet. There are a total of n different types of flowers in the store, each of which is characterized by the number of petals and the quantity of this type of flower. A flower with k petals costs k coins. The girl has decided that the difference in the number of petals between any two flowers she will use to decorate her cake should not exceed one. At the same time, the girl wants to assemble a bouquet with the maximum possible number of petals. Unfortunately, she only has m coins, and she cannot spend more. What is the maximum total number of petals she can assemble in the bouquet? Each test consists of several test cases. The first line contains a single integer t ( 1 <= t <= 10 ,000 ) -- the number of test cases. This is followed by descriptions of the test cases. The first line of each test case contains two integers n , m ( 1 <= n <= 2 cdot 10^5, 1 <= m <= 10^{18} ) -- the number of types of flowers in the store and the number of coins the girl possesses, respectively. The second line of each test case contains n different integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^9 ), where a_i is the number of petals of the i -th flower type in the store (for different indexes i neq j , it must be a_i neq a_j ). The third line of each test case contains n integers c_1, c_2, ldots, c_n ( 1 <= c_i <= 10^9 ), where c_i is the quantity of the i -th flower type in the store. The sum of n over all test cases does not exceed 2 cdot {10}^5 . For each test case, print one integer -- the maximum possible number of petals'...

Tutorials

Video Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
272176006 zrnstnsr B2 July 23, 2024, 5:21 p.m. OK C# 10 TESTS 15 405 30003200
272235966 sergio.moncada1 B2 July 24, 2024, 2:27 a.m. OK C++14 (GCC 6-32) TESTS 17 140 0
272241309 SOMXX B2 July 24, 2024, 3:18 a.m. OK C++14 (GCC 6-32) TESTS 17 155 0
272218425 WinterScroll424 B2 July 23, 2024, 9:20 p.m. OK C++14 (GCC 6-32) TESTS 17 155 1638400
272236493 729hao B2 July 24, 2024, 2:32 a.m. OK C++14 (GCC 6-32) TESTS 17 155 3276800
272233393 PR_vivi B2 July 24, 2024, 1:58 a.m. OK C++14 (GCC 6-32) TESTS 17 155 4812800
272221920 slime100 B2 July 23, 2024, 10:31 p.m. OK C++14 (GCC 6-32) TESTS 17 155 5836800
272205648 _toothless B2 July 23, 2024, 6:47 p.m. OK C++14 (GCC 6-32) TESTS 17 156 0
272244216 yanlikun B2 July 24, 2024, 3:47 a.m. OK C++14 (GCC 6-32) TESTS 17 156 3276800
272231212 bkl_1010 B2 July 24, 2024, 1:33 a.m. OK C++14 (GCC 6-32) TESTS 17 156 5836800
272216285 spraddyumn B2 July 23, 2024, 8:47 p.m. OK C++14 (GCC 6-32) TESTS 17 156 5836800
272220980 srrow_xhr B2 July 23, 2024, 10:10 p.m. OK C++17 (GCC 7-32) TESTS 17 140 0
272219215 pkhaustov B2 July 23, 2024, 9:34 p.m. OK C++17 (GCC 7-32) TESTS 17 140 0
272202566 saikrishna17394 B2 July 23, 2024, 6:21 p.m. OK C++17 (GCC 7-32) TESTS 17 140 0
272196483 devadathk001 B2 July 23, 2024, 5:39 p.m. OK C++17 (GCC 7-32) TESTS 15 140 0
272243751 hcedzsk B2 July 24, 2024, 3:41 a.m. OK C++17 (GCC 7-32) TESTS 17 140 1638400
272233410 _Amn_ B2 July 24, 2024, 1:59 a.m. OK C++17 (GCC 7-32) TESTS 17 140 5836800
272223713 arnavwinner B2 July 23, 2024, 11:16 p.m. OK C++17 (GCC 7-32) TESTS 17 155 0
272221211 srrow_xhr B2 July 23, 2024, 10:15 p.m. OK C++17 (GCC 7-32) TESTS 17 155 0
272220548 _shiina_ B2 July 23, 2024, 10:01 p.m. OK C++17 (GCC 7-32) TESTS 17 155 0
272216852 devsharma1322 B2 July 23, 2024, 8:55 p.m. OK C++17 (GCC 7-32) TESTS 17 155 0
272256852 hainam2009 B2 July 24, 2024, 5:59 a.m. OK C++20 (GCC 13-64) TESTS 17 109 1638400
272225578 fishcathu. B2 July 24, 2024, 12:05 a.m. OK C++20 (GCC 13-64) TESTS 17 109 1638400
272238560 Yoimiya_ B2 July 24, 2024, 2:52 a.m. OK C++20 (GCC 13-64) TESTS 17 109 3276800
272240503 iLing B2 July 24, 2024, 3:10 a.m. OK C++20 (GCC 13-64) TESTS 17 109 16076800
272256030 lujw B2 July 24, 2024, 5:52 a.m. OK C++20 (GCC 13-64) TESTS 17 124 0
272252772 rvmogre B2 July 24, 2024, 5:19 a.m. OK C++20 (GCC 13-64) TESTS 17 124 0
272252099 Venilv912 B2 July 24, 2024, 5:12 a.m. OK C++20 (GCC 13-64) TESTS 17 124 0
272249525 drizzle_codes B2 July 24, 2024, 4:46 a.m. OK C++20 (GCC 13-64) TESTS 17 124 0
272248878 MonoLith B2 July 24, 2024, 4:39 a.m. OK C++20 (GCC 13-64) TESTS 17 124 0
272248202 SharvanCN1 B2 July 24, 2024, 4:31 a.m. OK C++20 (GCC 13-64) TESTS 17 124 0
272220907 equal.tea6586 B2 July 23, 2024, 10:09 p.m. OK GNU C11 TESTS 17 171 3276800
272203524 RockingMat B2 July 23, 2024, 6:28 p.m. OK Java 21 TESTS 17 421 12185600
272248131 santuan B2 July 24, 2024, 4:30 a.m. OK Java 21 TESTS 17 468 13209600
272212497 daksh_02 B2 July 23, 2024, 7:59 p.m. OK Java 21 TESTS 17 483 11366400
272212427 dummypluser B2 July 23, 2024, 7:58 p.m. OK Java 21 TESTS 17 483 11366400
272174696 Baniya_09 B2 July 23, 2024, 5:15 p.m. OK Java 21 TESTS 15 515 11673600
272215617 rj3377295 B2 July 23, 2024, 8:37 p.m. OK Java 21 TESTS 17 561 33996800
272203689 akg_1111 B2 July 23, 2024, 6:29 p.m. OK Java 21 TESTS 17 593 92364800
272201971 vatsal_04 B2 July 23, 2024, 6:17 p.m. OK Java 21 TESTS 17 608 19353600
272255735 Sudip809 B2 July 24, 2024, 5:49 a.m. OK Java 21 TESTS 17 624 23756800
272249499 SweetAsCocaine B2 July 24, 2024, 4:46 a.m. OK Java 21 TESTS 17 640 30515200
272228951 kasinathan_sj B2 July 24, 2024, 1:02 a.m. OK Java 8 TESTS 17 390 23347200
272174631 om172 B2 July 23, 2024, 5:14 p.m. OK Java 8 TESTS 15 405 17612800
272248627 rjrajeevofficial B2 July 24, 2024, 4:36 a.m. OK Java 8 TESTS 17 421 22016000
272202820 profchi B2 July 23, 2024, 6:23 p.m. OK Java 8 TESTS 17 421 26521600
272209444 Techie_Himneesh B2 July 23, 2024, 7:25 p.m. OK Java 8 TESTS 17 437 30515200
272206036 Jay08 B2 July 23, 2024, 6:50 p.m. OK Java 8 TESTS 17 452 94720000
272197514 RebibeMeJett B2 July 23, 2024, 5:46 p.m. OK Java 8 TESTS 15 467 27136000
272204777 goodluck-ccq B2 July 23, 2024, 6:39 p.m. OK Java 8 TESTS 17 889 12902400
272205088 goodluck-ccq B2 July 23, 2024, 6:42 p.m. OK Java 8 TESTS 17 921 13004800
272216959 blkrop B2 July 23, 2024, 8:56 p.m. OK Kotlin 1.9 TESTS 17 702 33484800
272239759 nazeeftham007 B2 July 24, 2024, 3:03 a.m. OK PyPy 3 TESTS 17 905 27136000
272254157 lh_code B2 July 24, 2024, 5:33 a.m. OK PyPy 3 TESTS 17 1312 27033600
272221980 olisov_va B2 July 23, 2024, 10:32 p.m. OK PyPy 3-64 TESTS 17 265 38092800
272234067 smilences B2 July 24, 2024, 2:06 a.m. OK PyPy 3-64 TESTS 17 281 49664000
272214872 Hastey B2 July 23, 2024, 8:29 p.m. OK PyPy 3-64 TESTS 17 296 36352000
272173914 ntarsis30 B2 July 23, 2024, 5:12 p.m. OK PyPy 3-64 TESTS 15 296 39424000
272219199 anuragskadam B2 July 23, 2024, 9:34 p.m. OK PyPy 3-64 TESTS 17 296 45158400
272253382 accelerate_nju B2 July 24, 2024, 5:25 a.m. OK PyPy 3-64 TESTS 17 312 47411200
272173551 Horse-chan B2 July 23, 2024, 5:10 p.m. OK PyPy 3-64 TESTS 15 312 50176000
272229029 vtber B2 July 24, 2024, 1:03 a.m. OK PyPy 3-64 TESTS 17 327 33689600
272196506 soldierXboy B2 July 23, 2024, 5:39 p.m. OK PyPy 3-64 TESTS 15 343 41369600
272224623 twoo.zyy B2 July 23, 2024, 11:41 p.m. OK PyPy 3-64 TESTS 17 374 44851200
272245762 Minh20112009 dona10khoa_nhd B2 July 24, 2024, 4:03 a.m. OK Python 3 TESTS 17 515 62464000
272171178 sarkardhiraj279 B2 July 23, 2024, 4:34 p.m. OK Python 3 TESTS 15 530 37888000
272199067 adhnandath B2 July 23, 2024, 5:56 p.m. OK Python 3 TESTS 15 562 36249600
272210128 Ahsan612 B2 July 23, 2024, 7:31 p.m. OK Python 3 TESTS 17 640 36454400
272213999 kizago B2 July 23, 2024, 8:18 p.m. OK Python 3 TESTS 17 718 35123200
272256915 vamsi_odyssey B2 July 24, 2024, 6 a.m. OK Python 3 TESTS 17 718 43520000
272208845 phantomxxx B2 July 23, 2024, 7:19 p.m. OK Python 3 TESTS 17 843 40038400
272234677 bqn B2 July 24, 2024, 2:13 a.m. OK Rust 2021 TESTS 17 139 8704000
272212989 fieubat2x B2 July 23, 2024, 8:05 p.m. OK Rust 2021 TESTS 17 140 23859200
272200304 Cheshulko B2 July 23, 2024, 6:04 p.m. OK Rust 2021 TESTS 17 171 20172800
272210652 fieubat2x B2 July 23, 2024, 7:38 p.m. OK Rust 2021 TESTS 17 171 23961600

remove filters

Back to search problems