Codeforces Round 657 (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
1379 Codeforces Round 657 (Div. 2) FINISHED False 7200 142030763 July 19, 2020, 9 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 5665 ) C Choosing flowers PROGRAMMING binary search data structures greedy math sortings two pointers 2000

B"Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly n flowers. Vladimir went to a flower shop, and he was amazed to see that there are m types of flowers being sold there, and there is unlimited supply of flowers of each type. Vladimir wants to choose flowers to maximize the happiness of his wife. He knows that after receiving the first flower of the i -th type happiness of his wife increases by a_i and after receiving each consecutive flower of this type her happiness increases by b_i . That is, if among the chosen flowers there are x_i > 0 flowers of type i , his wife gets a_i + (x_i - 1) cdot b_i additional happiness (and if there are no flowers of type i , she gets nothing for this particular type). Please help Vladimir to choose exactly n flowers to maximize the total happiness of his wife. The first line contains the only integer t ( 1 <= q t <= q 10 ,000 ), the number of test cases. It is followed by t descriptions of the test cases. Each test case description starts with two integers n and m ( 1 <= n <= 10^9 , 1 <= m <= 100 ,000 ), the number of flowers Vladimir needs to choose and the number of types of available flowers. The following m lines describe the types of flowers: each line contains integers a_i and b_i ( 0 <= a_i, b_i <= 10^9 ) for i -th available type of flowers. The test cases are separated by a blank line. It is guaranteed that the sum of values m among all test cases does not exceed 100 ,000 . For each test case output a single integer: the maximum total happiness of Vladimir's wife after choosing exactly n flowers optimally. In the first example case Vladimir can pick 1 flower of the first type and 3 flowers of the second type, in this case the total happiness equals 5 + (1 + 2 cdot 4) = 14 . In the second example Vladimir can"...

Tutorials

Codeforces Round #657 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
87353315 Renne_Candy C July 19, 2020, 12:52 p.m. OK Clang++17 Diagnostics TESTS 32 280 280883200 2000
87332328 Gassa C July 19, 2020, 10:39 a.m. OK D TESTS 32 109 10854400 2000
87317241 litble C July 19, 2020, 10:05 a.m. OK GNU C++11 TESTS 32 46 5529600 2000
87330721 jxm2001 C July 19, 2020, 10:35 a.m. OK GNU C++11 TESTS 32 46 5939200 2000
87329670 Angel_Demon C July 19, 2020, 10:32 a.m. OK GNU C++11 TESTS 32 46 5939200 2000
87319559 Sweetlemon C July 19, 2020, 10:10 a.m. OK GNU C++11 TESTS 32 46 8499200 2000
87347196 yy_makemelove C July 19, 2020, 11:54 a.m. OK GNU C++11 TESTS 32 46 23961600 2000
87369259 spnooyseed C July 19, 2020, 3:50 p.m. OK GNU C++11 TESTS 32 46 35942400 2000
87350696 WaluntOvO C July 19, 2020, 12:26 p.m. OK GNU C++11 TESTS 32 46 35942400 2000
87314891 QieziMin C July 19, 2020, 10 a.m. OK GNU C++11 TESTS 32 46 36147200 2000
87344940 DarkoLoveRuby C July 19, 2020, 11:37 a.m. OK GNU C++11 TESTS 32 61 5734400 2000
87389612 2016wudi C July 20, 2020, 12:16 a.m. OK GNU C++11 TESTS 32 61 5939200 2000
87310579 Depth_First_Search C July 19, 2020, 9:51 a.m. OK GNU C++14 TESTS 32 46 5427200 2000
87308563 Linkus C July 19, 2020, 9:47 a.m. OK GNU C++14 TESTS 32 61 7987200 2000
87356819 MochaLatte C July 19, 2020, 1:32 p.m. OK GNU C++14 TESTS 32 77 5324800 2000
87312666 Cxfaner C July 19, 2020, 9:55 a.m. OK GNU C++14 TESTS 32 78 5324800 2000
87342479 gemini_man C July 19, 2020, 10:59 a.m. OK GNU C++14 TESTS 32 78 5734400 2000
87329847 Luzivanlt C July 19, 2020, 10:33 a.m. OK GNU C++14 TESTS 32 78 6144000 2000
87329487 scli_kjh C July 19, 2020, 10:32 a.m. OK GNU C++14 TESTS 32 78 6144000 2000
87316166 ABPower C July 19, 2020, 10:02 a.m. OK GNU C++14 TESTS 32 78 6144000 2000
87314876 Scut82 C July 19, 2020, 10 a.m. OK GNU C++14 TESTS 32 78 6553600 2000
87380323 harryamneet600 C July 19, 2020, 6:59 p.m. OK GNU C++14 TESTS 32 78 6963200 2000
87309167 wiwitrifai C July 19, 2020, 9:49 a.m. OK GNU C++17 TESTS 32 77 5324800 2000
87382422 avocado_aguila C July 19, 2020, 7:45 p.m. OK GNU C++17 TESTS 32 77 5529600 2000
87330742 feiko C July 19, 2020, 10:35 a.m. OK GNU C++17 TESTS 32 77 7270400 2000
87375695 Medeowex C July 19, 2020, 5:31 p.m. OK GNU C++17 TESTS 32 77 8294400 2000
87344498 _Clouder C July 19, 2020, 11:35 a.m. OK GNU C++17 TESTS 32 77 10649600 2000
87331386 zhangwen123 C July 19, 2020, 10:36 a.m. OK GNU C++17 TESTS 32 77 10956800 2000
87356088 hzeroto C July 19, 2020, 1:24 p.m. OK GNU C++17 TESTS 32 77 11776000 2000
87325234 thuanqvbn03 C July 19, 2020, 10:22 a.m. OK GNU C++17 TESTS 32 78 4915200 2000
87369357 yangyuchen C July 19, 2020, 3:51 p.m. OK GNU C++17 TESTS 32 78 5324800 2000
87352878 anodiebird C July 19, 2020, 12:48 p.m. OK GNU C++17 TESTS 32 78 5324800 2000
87361684 hello_codeforces C July 19, 2020, 2:24 p.m. OK GNU C++17 (64) TESTS 32 62 5939200 2000
87360737 hello_codeforces C July 19, 2020, 2:14 p.m. OK GNU C++17 (64) TESTS 32 62 5939200 2000
87321444 Eureka17 C July 19, 2020, 10:14 a.m. OK GNU C++17 (64) TESTS 32 62 5939200 2000
87351327 ianahao C July 19, 2020, 12:33 p.m. OK GNU C++17 (64) TESTS 32 62 6348800 2000
87348230 dna049 C July 19, 2020, 12:03 p.m. OK GNU C++17 (64) TESTS 32 62 6348800 2000
87334491 qdd C July 19, 2020, 10:43 a.m. OK GNU C++17 (64) TESTS 32 62 6348800 2000
87315719 EmilConst C July 19, 2020, 10:02 a.m. OK GNU C++17 (64) TESTS 32 62 6451200 2000
87371359 dynam1c C July 19, 2020, 4:19 p.m. OK GNU C++17 (64) TESTS 32 62 6758400 2000
87366182 universe- C July 19, 2020, 3:13 p.m. OK GNU C++17 (64) TESTS 32 62 6758400 2000
87344635 scol C July 19, 2020, 11:35 a.m. OK GNU C++17 (64) TESTS 32 62 6758400 2000
87316284 insert_cool_handle C July 19, 2020, 10:03 a.m. OK Java 11 TESTS 32 249 24371200 2000
87344909 _apurv_ C July 19, 2020, 11:37 a.m. OK Java 11 TESTS 32 264 24371200 2000
87365062 AhmedZ C July 19, 2020, 2:59 p.m. OK Java 11 TESTS 32 280 24371200 2000
87352214 idk321 C July 19, 2020, 12:41 p.m. OK Java 11 TESTS 32 280 24473600 2000
87383342 an09mous C July 19, 2020, 8:07 p.m. OK Java 11 TESTS 32 280 24576000 2000
87351551 chris_11 C July 19, 2020, 12:35 p.m. OK Java 11 TESTS 32 280 24576000 2000
87345819 _apurv_ C July 19, 2020, 11:43 a.m. OK Java 11 TESTS 32 296 24371200 2000
87359378 Apfeloxid C July 19, 2020, 1:59 p.m. OK Java 11 TESTS 32 296 24780800 2000
87326945 rohan03 C July 19, 2020, 10:26 a.m. OK Java 11 TESTS 32 483 44441600 2000
87347961 nirvana_rsc C July 19, 2020, 12:01 p.m. OK Java 11 TESTS 32 529 25088000 2000
87376410 KharYusuf C July 19, 2020, 5:44 p.m. OK Java 8 TESTS 32 171 21401600 2000
87376361 KharYusuf C July 19, 2020, 5:43 p.m. OK Java 8 TESTS 32 187 21401600 2000
87333394 Naman_123 C July 19, 2020, 10:41 a.m. OK Java 8 TESTS 32 187 21504000 2000
87325077 BNL C July 19, 2020, 10:22 a.m. OK Java 8 TESTS 32 202 21196800 2000
87363592 AshrafEzz C July 19, 2020, 2:44 p.m. OK Java 8 TESTS 32 202 21299200 2000
87376058 KharYusuf C July 19, 2020, 5:38 p.m. OK Java 8 TESTS 32 202 21401600 2000
87369151 Me146 C July 19, 2020, 3:49 p.m. OK Java 8 TESTS 32 217 21196800 2000
87366628 Whiplash99 C July 19, 2020, 3:18 p.m. OK Java 8 TESTS 32 218 21196800 2000
87326486 2u_my_light C July 19, 2020, 10:25 a.m. OK Java 8 TESTS 32 218 21196800 2000
87364787 mikhail.mints C July 19, 2020, 2:57 p.m. OK Java 8 TESTS 32 233 21196800 2000
87333627 ekaerovets C July 19, 2020, 10:42 a.m. OK Kotlin TESTS 32 264 22528000 2000
87364437 Tlatoani C July 19, 2020, 2:53 p.m. OK Kotlin TESTS 32 358 26112000 2000
87368141 golions C July 19, 2020, 3:36 p.m. OK Kotlin TESTS 32 358 28876800 2000
87335087 sultazat C July 19, 2020, 10:45 a.m. OK Kotlin TESTS 32 561 26521600 2000
87344400 terry_u16 C July 19, 2020, 11:34 a.m. OK Mono C# TESTS 32 186 14131200 2000
87339095 kuuso C July 19, 2020, 10:53 a.m. OK Mono C# TESTS 32 202 17612800 2000
87336929 hibatibati C July 19, 2020, 10:49 a.m. OK Mono C# TESTS 32 249 20992000 2000
87344602 hibatibati C July 19, 2020, 11:35 a.m. OK Mono C# TESTS 32 249 20992000 2000
87309040 fiver C July 19, 2020, 9:48 a.m. OK Mono C# TESTS 32 576 232755200 2000
87312852 Pnn1337 C July 19, 2020, 9:56 a.m. OK MS C++ 2017 TESTS 32 108 8396800 2000
87364141 TMHazem C July 19, 2020, 2:50 p.m. OK MS C++ 2017 TESTS 32 109 8499200 2000
87354284 The.Cursed.Mage C July 19, 2020, 1:02 p.m. OK MS C++ 2017 TESTS 32 109 8499200 2000
87367118 little_lion C July 19, 2020, 3:24 p.m. OK MS C++ 2017 TESTS 32 218 6656000 2000
87332299 kupriyanov C July 19, 2020, 10:39 a.m. OK MS C++ 2017 TESTS 32 218 9728000 2000
87357949 Eternalll C July 19, 2020, 1:43 p.m. OK MS C++ 2017 TESTS 32 233 6963200 2000
87381378 1dayac C July 19, 2020, 7:22 p.m. OK MS C++ 2017 TESTS 32 249 11468800 2000
87345576 realnimish C July 19, 2020, 11:42 a.m. OK PyPy 2 TESTS 32 623 41267200 2000
87386112 vinay272001 C July 19, 2020, 9:29 p.m. OK PyPy 2 TESTS 32 748 38092800 2000
87326524 raj1307 C July 19, 2020, 10:25 a.m. OK PyPy 2 TESTS 32 826 48947200 2000
87386283 daigakupotato C July 19, 2020, 9:35 p.m. OK PyPy 3 TESTS 32 421 37376000 2000
87339306 kclee2172 C July 19, 2020, 10:54 a.m. OK PyPy 3 TESTS 32 436 33689600 2000
87358619 Mahipalkeizer C July 19, 2020, 1:50 p.m. OK PyPy 3 TESTS 32 467 43724800 2000
87374699 Coki628 C July 19, 2020, 5:14 p.m. OK PyPy 3 TESTS 32 514 36352000 2000
87370088 ryo_n C July 19, 2020, 4:01 p.m. OK PyPy 3 TESTS 32 514 40038400 2000
87373935 Coki628 C July 19, 2020, 5:01 p.m. OK PyPy 3 TESTS 32 530 36352000 2000
87351212 tanon710 C July 19, 2020, 12:31 p.m. OK PyPy 3 TESTS 32 530 40345600 2000
87355036 manish.17 C July 19, 2020, 1:11 p.m. OK PyPy 3 TESTS 32 545 39321600 2000
87336117 lowking C July 19, 2020, 10:47 a.m. OK PyPy 3 TESTS 32 561 37478400 2000
87344903 xuanji C July 19, 2020, 11:37 a.m. OK PyPy 3 TESTS 32 577 35123200 2000
87384898 Bluefish2 C July 19, 2020, 8:49 p.m. OK Python 2 TESTS 32 982 22937600 2000
87387285 alon276 C July 19, 2020, 10:15 p.m. OK Python 3 TESTS 32 467 21196800 2000
87341448 liteburn C July 19, 2020, 10:58 a.m. OK Python 3 TESTS 32 499 18329600 2000
87346431 sh1194 C July 19, 2020, 11:48 a.m. OK Python 3 TESTS 32 592 15564800 2000
87346879 sh1194 C July 19, 2020, 11:51 a.m. OK Python 3 TESTS 32 608 15564800 2000
87346751 sh1194 C July 19, 2020, 11:50 a.m. OK Python 3 TESTS 32 623 15564800 2000
87389585 shamio C July 20, 2020, 12:14 a.m. OK Python 3 TESTS 32 655 20582400 2000
87323653 shamio C July 19, 2020, 10:19 a.m. OK Python 3 TESTS 32 655 20582400 2000
87383392 Ayushman_500 C July 19, 2020, 8:08 p.m. OK Python 3 TESTS 32 670 20787200 2000
87372354 zapdospops C July 19, 2020, 4:35 p.m. OK Python 3 TESTS 32 670 21196800 2000
87332639 potpath C July 19, 2020, 10:39 a.m. OK Python 3 TESTS 32 701 15667200 2000
87387294 komorin95 C July 19, 2020, 10:15 p.m. OK Rust TESTS 32 62 10137600 2000
87340718 terraformer C July 19, 2020, 10:57 a.m. OK Rust TESTS 32 124 7475200 2000
87324128 robostac C July 19, 2020, 10:20 a.m. OK Rust TESTS 32 139 6451200 2000
87342163 wweihao.zj C July 19, 2020, 10:59 a.m. OK Rust TESTS 32 171 9625600 2000

remove filters

Back to search problems