Codeforces Round 559 (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
1158 Codeforces Round 559 (Div. 1) FINISHED False 7200 174151499 May 12, 2019, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 7207 ) A The Party and Sweets PROGRAMMING binary search constructive algorithms greedy implementation math sortings two pointers 1500

B' n boys and m girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from 1 to n and all girls are numbered with integers from 1 to m . For all 1 <= q i <= q n the minimal number of sweets, which i -th boy presented to some girl is equal to b_i and for all 1 <= q j <= q m the maximal number of sweets, which j -th girl received from some boy is equal to g_j . More formally, let a_{i,j} be the number of sweets which the i -th boy give to the j -th girl. Then b_i is equal exactly to the minimum among values a_{i,1}, a_{i,2}, ldots, a_{i,m} and g_j is equal exactly to the maximum among values b_{1,j}, b_{2,j}, ldots, b_{n,j} . You are interested in the minimum total number of sweets that boys could present, so you need to minimize the sum of a_{i,j} for all (i,j) such that 1 <= q i <= q n and 1 <= q j <= q m . You are given the numbers b_1, ldots, b_n and g_1, ldots, g_m , determine this number. The first line contains two integers n and m , separated with space -- the number of boys and girls, respectively ( 2 <= q n, m <= q 100 ,000 ). The second line contains n integers b_1, ldots, b_n , separated by spaces -- b_i is equal to the minimal number of sweets, which i -th boy presented to some girl ( 0 <= q b_i <= q 10^8 ). The third line contains m integers g_1, ldots, g_m , separated by spaces -- g_j is equal to the maximal number of sweets, which j -th girl received from some boy ( 0 <= q g_j <= q 10^8 ). If the described situation is impossible, print -1 . In another case, print the minimal total number of sweets, which boys could have presented and all conditions could have satisfied. In the first test, the minimal total number of sweets, which boys could '...

Tutorials

66993

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
64722253 luogu_bot2 A Nov. 12, 2019, 4:33 a.m. OK FPC TESTS 102 77 204800 1500
54251982 about A May 16, 2019, 5:43 p.m. OK GNU C11 TESTS 102 62 0 1500
54056019 sazidnur A May 13, 2019, 8:18 a.m. OK GNU C11 TESTS 102 77 1638400 1500
54993192 _nmp_ A June 2, 2019, 8:27 p.m. OK GNU C11 TESTS 102 93 1638400 1500
54993175 _nmp_ A June 2, 2019, 8:26 p.m. OK GNU C11 TESTS 102 93 1638400 1500
54993105 _nmp_ A June 2, 2019, 8:22 p.m. OK GNU C11 TESTS 102 93 1638400 1500
54053753 memset0c A May 13, 2019, 6:38 a.m. OK GNU C++11 TESTS 102 31 819200 1500
54876015 litble A May 31, 2019, 11:51 a.m. OK GNU C++11 TESTS 102 31 819200 1500
55486120 luogu_bot4 A June 12, 2019, 7:56 a.m. OK GNU C++11 TESTS 102 46 0 1500
54056144 luogu_bot1 A May 13, 2019, 8:22 a.m. OK GNU C++11 TESTS 102 46 819200 1500
54820201 Clao_015 A May 30, 2019, 1:39 a.m. OK GNU C++11 TESTS 102 46 819200 1500
55060741 justin_cao A June 3, 2019, 10:24 p.m. OK GNU C++11 TESTS 102 46 819200 1500
55610944 ReaLNero1 A June 16, 2019, 5:41 a.m. OK GNU C++11 TESTS 102 46 819200 1500
68356997 luogu_bot3 A Jan. 7, 2020, 12:31 p.m. OK GNU C++11 TESTS 102 46 819200 1500
68367815 luogu_bot2 A Jan. 7, 2020, 4:38 p.m. OK GNU C++11 TESTS 102 46 819200 1500
54261336 msuwakow A May 17, 2019, 2:04 a.m. OK GNU C++11 TESTS 102 46 921600 1500
54403126 FizzyDavid A May 20, 2019, 3:16 a.m. OK GNU C++14 TESTS 102 46 921600 1500
54434851 aid A May 21, 2019, 4:26 a.m. OK GNU C++14 TESTS 102 62 819200 1500
54030983 Linkus A May 12, 2019, 2:49 p.m. OK GNU C++14 TESTS 102 62 1638400 1500
54866626 Mr_Mafia A May 31, 2019, 6:38 a.m. OK GNU C++14 TESTS 102 77 0 1500
54097620 michael.dotsenko A May 14, 2019, 1:56 p.m. OK GNU C++14 TESTS 102 77 819200 1500
54038998 Motarack A May 12, 2019, 3:38 p.m. OK GNU C++14 TESTS 102 77 819200 1500
54032798 pikmike A May 12, 2019, 2:58 p.m. OK GNU C++14 TESTS 102 77 819200 1500
54031309 natsugiri A May 12, 2019, 2:51 p.m. OK GNU C++14 TESTS 102 77 819200 1500
54030990 gs15120 A May 12, 2019, 2:49 p.m. OK GNU C++14 TESTS 102 77 921600 1500
62385680 I_love_simplespy A Oct. 11, 2019, 9:13 p.m. OK GNU C++14 TESTS 102 77 1638400 1500
54037531 lesskreker A May 12, 2019, 3:27 p.m. OK GNU C++17 TESTS 102 46 819200 1500
54262052 LiChenKoh A May 17, 2019, 2:48 a.m. OK GNU C++17 TESTS 102 46 1638400 1500
54032518 interestingLSY A May 12, 2019, 2:57 p.m. OK GNU C++17 TESTS 102 46 4198400 1500
54085708 whzzt A May 14, 2019, 7:13 a.m. OK GNU C++17 TESTS 102 46 5427200 1500
54048064 kessido A May 12, 2019, 6:19 p.m. OK GNU C++17 TESTS 102 62 2867200 1500
64598603 Antygenius A Nov. 9, 2019, 5:45 p.m. OK GNU C++17 TESTS 102 77 0 1500
54159373 Elegia A May 15, 2019, 5:49 a.m. OK GNU C++17 TESTS 102 77 819200 1500
54031187 KADR A May 12, 2019, 2:50 p.m. OK GNU C++17 TESTS 102 77 819200 1500
54032141 hiThere23 A May 12, 2019, 2:55 p.m. OK GNU C++17 TESTS 102 77 819200 1500
54090341 train_driver A May 14, 2019, 10:27 a.m. OK GNU C++17 TESTS 102 77 819200 1500
55515727 prem_cse A June 13, 2019, 5:07 a.m. OK Java 8 TESTS 102 124 0 1500
54035622 dalt A May 12, 2019, 3:15 p.m. OK Java 8 TESTS 102 140 0 1500
54042549 uwi A May 12, 2019, 4:07 p.m. OK Java 8 TESTS 102 140 0 1500
55053820 analog A June 3, 2019, 6:12 p.m. OK Java 8 TESTS 102 155 0 1500
54534667 holeguma A May 23, 2019, 7:12 p.m. OK Java 8 TESTS 102 155 0 1500
54082742 xodiac A May 14, 2019, 4:59 a.m. OK Java 8 TESTS 102 155 0 1500
60354759 i_will_be_less_than_blue A Sept. 10, 2019, 3:41 p.m. OK Java 8 TESTS 102 171 0 1500
59615531 ISSAM_LAKOUAM A Aug. 28, 2019, 12:32 p.m. OK Java 8 TESTS 102 171 0 1500
54072937 4mda4mda A May 13, 2019, 5:33 p.m. OK Java 8 TESTS 102 171 1433600 1500
54051778 darnley A May 12, 2019, 9:02 p.m. OK Java 8 TESTS 102 171 2867200 1500
54588423 kotter A May 25, 2019, 7:45 a.m. OK Kotlin TESTS 102 327 11571200 1500
54032031 elizarov A May 12, 2019, 2:54 p.m. OK Kotlin TESTS 102 358 1331200 1500
54033707 ymatsux A May 12, 2019, 3:04 p.m. OK Kotlin TESTS 102 389 3584000 1500
56525705 og.kostya A July 4, 2019, 5:03 p.m. OK Mono C# TESTS 102 93 4403200 1500
54070803 TrabajoNocturno A May 13, 2019, 4:08 p.m. OK Mono C# TESTS 102 217 104448000 1500
59208282 vjudge5 A Aug. 21, 2019, 7:42 a.m. OK MS C++ TESTS 102 78 819200 1500
57310217 vjudge4 A July 19, 2019, 6:08 a.m. OK MS C++ TESTS 102 78 1228800 1500
59199071 vjudge2 A Aug. 21, 2019, 3:29 a.m. OK MS C++ TESTS 102 78 1638400 1500
54063233 vjudge3 A May 13, 2019, 12:12 p.m. OK MS C++ TESTS 102 78 1638400 1500
65705008 vjudge3 A Nov. 25, 2019, 12:13 p.m. OK MS C++ TESTS 102 93 1638400 1500
59206695 vjudge1 A Aug. 21, 2019, 7:10 a.m. OK MS C++ TESTS 102 140 819200 1500
65799061 vjudge4 A Nov. 27, 2019, 6:35 a.m. OK MS C++ TESTS 102 202 1638400 1500
59706156 j2v A Aug. 30, 2019, 12:44 p.m. OK MS C++ 2017 TESTS 102 93 1228800 1500
58081625 vjudge5 A July 31, 2019, 2:05 p.m. OK MS C++ 2017 TESTS 102 93 1638400 1500
54522973 shoulinniao A May 23, 2019, 1:07 p.m. OK MS C++ 2017 TESTS 102 93 1638400 1500
68908034 AleksanderBalobanov A Jan. 16, 2020, 7:08 a.m. OK MS C++ 2017 TESTS 102 93 8294400 1500
54095241 hjp20186489 A May 14, 2019, 12:46 p.m. OK MS C++ 2017 TESTS 102 109 1638400 1500
55481324 BessieTheCow A June 12, 2019, 5:23 a.m. OK MS C++ 2017 TESTS 102 202 0 1500
54443388 Still_Theory A May 21, 2019, 9:56 a.m. OK MS C++ 2017 TESTS 102 218 3174400 1500
54033063 ielenik A May 12, 2019, 2:59 p.m. OK MS C++ 2017 TESTS 102 233 819200 1500
54031875 rainor A May 12, 2019, 2:53 p.m. OK MS C++ 2017 TESTS 102 234 1638400 1500
58704836 EverRest A Aug. 13, 2019, 9:05 a.m. OK MS C++ 2017 TESTS 102 234 1638400 1500
54982262 bupt.wc A June 2, 2019, 1:47 p.m. OK PyPy 2 TESTS 102 187 10752000 1500
69859505 SoSooding A Jan. 30, 2020, 6:03 p.m. OK PyPy 2 TESTS 102 202 11059200 1500
54059965 Cifko A May 13, 2019, 10:40 a.m. OK PyPy 2 TESTS 102 327 14438400 1500
54030935 ManasG A May 12, 2019, 2:49 p.m. OK PyPy 2 TESTS 102 374 16793600 1500
54346944 shubham0007 A May 18, 2019, 12:55 p.m. OK PyPy 3 TESTS 102 295 16281600 1500
54057398 llbra9z A May 13, 2019, 9:09 a.m. OK PyPy 3 TESTS 102 296 15667200 1500
54346123 modestas_ A May 18, 2019, 12:32 p.m. OK PyPy 3 TESTS 102 312 16179200 1500
54033164 titia A May 12, 2019, 3 p.m. OK PyPy 3 TESTS 102 327 12800000 1500
54033228 Kiri8128 A May 12, 2019, 3 p.m. OK PyPy 3 TESTS 102 342 17100800 1500
62908358 UTMoonlight A Oct. 19, 2019, 6:32 a.m. OK PyPy 3 TESTS 102 374 15974400 1500
61807445 irza_law A Oct. 3, 2019, 10:50 p.m. OK PyPy 3 TESTS 102 389 15667200 1500
56283194 artifexbm A June 29, 2019, 5:58 p.m. OK PyPy 3 TESTS 102 468 16896000 1500
54032712 nwi A May 12, 2019, 2:58 p.m. OK Python 2 TESTS 102 296 7782400 1500
58671825 soumyasarkar1998 A Aug. 12, 2019, 2:43 p.m. OK Python 2 TESTS 102 358 7884800 1500
57760408 Muskan2211 A July 25, 2019, 5:47 p.m. OK Python 3 TESTS 102 202 10547200 1500
55626368 sdhd A June 16, 2019, 10:01 a.m. OK Python 3 TESTS 102 202 10649600 1500
54378931 monkeydluffy A May 19, 2019, 10:01 a.m. OK Python 3 TESTS 102 218 10547200 1500
54029968 whatshisbucket A May 12, 2019, 2:44 p.m. OK Python 3 TESTS 102 218 10854400 1500
55225233 ZZZJOOO A June 7, 2019, 12:21 a.m. OK Python 3 TESTS 102 233 10956800 1500
54470727 burhonbaqoyev A May 22, 2019, 5:16 a.m. OK Python 3 TESTS 102 249 10854400 1500
54439937 akshat8171 A May 21, 2019, 8:04 a.m. OK Python 3 TESTS 102 249 10956800 1500
54425008 youness.amhaouch A May 20, 2019, 5:48 p.m. OK Python 3 TESTS 102 249 10956800 1500
61514749 V-AbuALI-V A Sept. 29, 2019, 5:08 p.m. OK Python 3 TESTS 102 265 10547200 1500
54056221 SYHNE A May 13, 2019, 8:25 a.m. OK Python 3 TESTS 102 265 10547200 1500
59968219 sansen A Sept. 3, 2019, 10:11 p.m. OK Rust TESTS 102 78 7270400 1500
54034084 limed A May 12, 2019, 3:06 p.m. OK Scala TESTS 102 655 4096000 1500

remove filters

Back to search problems